Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

http-post-simple.el -- (lambda (field) ...) quoted with ' rather than with #'

Tags:

emacs

Could someone please give me a hand debugging http-post-simple.el for use with the latest version of Emacs Trunk: http://www.emacswiki.org/emacs/http-post-simple.el This is a required file for using the Org-Mode Toodledo Sync. When opening Emacs, the error message is:

(lambda (field) ...) quoted with ' rather than with #'

The excerpt from http-post-simple.el where the error is coming from is as follows:

(defun http-post-encode-fields (fields &optional charset)
  "Encode FIELDS using `http-post-encode-string', where
FIELDS is an alist of \(
    \(field-name-as-symbol . \"field value as string\"\) |
    \(field-name \"value1\" \"value2\" ...\)
    \)*

CHARSET defaults to 'utf-8"
  (let ((charset (or charset 'utf-8)))
    (mapconcat #'identity
           (mapcar '(lambda (field)
             (concat (symbol-name (car field))
              "="
              (http-post-encode-string (cdr field) charset)))
               (mapcan '(lambda (field)
                 (if (atom (cdr field)) (list field)
                     ;; unpack the list
                     (mapcar '(lambda (value)
                           `(,(car field) . ,value))
                         (cdr field))))
                   fields))
           "&")))


(defun http-post-encode-multipart-data (fields files charset)
  "Return FIELDS and FILES encoded for use as the data for a multipart HTTP POST request"
  (http-post-join-lines
   (mapcar '(lambda (field)
         (http-post-bound-field
          (format "Content-Disposition: form-data; name=%S" (symbol-name (car field)))
          ""
          (cdr field)))
       fields)
   (mapcan '(lambda (file)
         (destructuring-bind (fieldname filename mime-type data) file
           (http-post-bound-field
        (format "Content-Disposition: form-data; name=%S; filename=%S" fieldname filename)
        (format "Content-type: %s" (http-post-content-type mime-type charset))
        ""
        data)))
       files)
   (format "--%s--" (http-post-multipart-boundary))))
like image 780
lawlist Avatar asked Apr 21 '26 23:04

lawlist


1 Answers

You generally don't want to quote lambda expressions with '.

(lambda) is self-quoting and equivalent to #'(lambda), but '(lambda) is not the same thing.

See When should Emacs #'function syntax be used?

like image 123
phils Avatar answered Apr 24 '26 10:04

phils



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!