0

I have the following function to produce a form that can be "printed" to a ~/.gnus file to configure gnus to use a certain stmp and imap server for an account:

(defun gnus-imap-smtp-form (email smtp-server-port imap-server-port)
  (destructuring-bind ((smtp-server . smtp-port) . (imap-server . imap-port))
      (cons smtp-server-port imap-server-port)
    `(let ((email ,email)
       (smtp-server ,smtp-server)
       (smtp-port ,smtp-port)
       (imap-server ,imap-server)
       (imap-port ,imap-port))
       (setf gnus-select-method
         `(nnimap ,email
              (nnimap-address ,imap-server)
              (nnimap-server-port ,imap-port)
              (nnimap-stream ssl)))

       (setf message-send-mail-function 'smtpmail-send-it
         smtpmail-starttls-credentials `((,smtp-server ,smtp-port nil nil))
         smtpmail-auth-credentials `((,smtp-server ,smtp-port
                               ,email nil))
         smtpmail-default-smtp-server smtp-server
         smtpmail-smtp-server smtp-server
         smtpmail-smtp-service smtp-port
         gnus-ignored-newsgroups
         "^to\\.\\|^[0-9. ]+\\( \\|$\\)\\|^[\"]\"[#'()]")

       (setf user-mail-address email)
       (setf smtpmail-stream-type 'starttls))))

In the past, the above has generated the correct form:

(gnus-imap-smtp-form "me@company.com" '("my.company.smtp" . 587) '("my.company.imap" . 993))


(let
       ((email "me@company.com")
        (smtp-server "my.company.smtp")
        (smtp-port 25)
        (imap-server "my.company.imap")
        (imap-port 993))
     (setf gnus-select-method
           `(nnimap ,email
            (nnimap-address ,imap-server)
            (nnimap-server-port ,imap-port)
            (nnimap-stream ssl)))
     (setf message-send-mail-function 'smtpmail-send-it smtpmail-starttls-credentials
           `((,smtp-server ,smtp-port nil nil))
           smtpmail-auth-credentials
           `((,smtp-server ,smtp-port ,email nil))
           smtpmail-default-smtp-server smtp-server smtpmail-smtp-server smtp-server smtpmail-smtp-service smtp-port gnus-ignored-newsgroups "^to\\.\\|^[0-9. ]+\\( \\|$\\)\\|^[\"]\"[#'()]")
     (setf user-mail-address email)
     (setf smtpmail-stream-type 'starttls))

Today, I tried to generate the form for another account, but I am getting triple dots ... instead of nested backquotes:

(gnus-imap-smtp-form "me@gmail.com" '("smtp.gmail.com" . 587) '("imap.gmail.com" . 993)) 


    (let
    ((email "me@gmail.com")
     (smtp-server "smtp.gmail.com")
     (smtp-port 587)
     (imap-server "imap.gmail.com")
     (imap-port 993))
  (setf gnus-select-method
    `(nnimap ... ... ... ...))
  (setf message-send-mail-function 'smtpmail-send-it smtpmail-starttls-credentials
    `(...)
    smtpmail-auth-credentials
    `(...)
    smtpmail-default-smtp-server smtp-server smtpmail-smtp-server smtp-server smtpmail-smtp-service ...)
  (setf user-mail-address email)
  (setf smtpmail-stream-type 'starttls))

What could be happening?

I've tried (prin1 form), let-binding to nil both eval-expression-print-length and eval-expression-print-level, but prin1 still abbreviates the expression:

(let ((eval-expression-print-length nil)
      (eval-expression-print-level nil))
      (prin1 form))
(let ((email "me@gmail.com") (smtp-server "smtp.gmail.com") (smtp-port 587) (imap-server "imap.gmail.com") (imap-port 993)) (setf gnus-select-method (\` (nnimap ... ... ... ...))) (setf message-send-mail-function (quote smtpmail-send-it) smtpmail-starttls-credentials (\` (...)) smtpmail-auth-credentials (\` (...)) smtpmail-default-smtp-server smtp-server smtpmail-smtp-server smtp-server smtpmail-smtp-service ...) (setf user-mail-address email) (setf smtpmail-stream-type (quote starttls)))
(let
    ((email "me@gmail.com")
     (smtp-server "smtp.gmail.com")
     (smtp-port 587)
     (imap-server "imap.gmail.com")
     (imap-port 993))
  (setf gnus-select-method
    `(nnimap ... ... ... ...))
  (setf message-send-mail-function 'smtpmail-send-it smtpmail-starttls-credentials
    `(...)
    smtpmail-auth-credentials
    `(...)
    smtpmail-default-smtp-server smtp-server smtpmail-smtp-server smtp-server smtpmail-smtp-service ...)
  (setf user-mail-address email)
  (setf smtpmail-stream-type 'starttls))

Binding print-level and print-length:

(let ((eval-expression-print-length nil)
         (eval-expression-print-level nil)
         (print-level nil)
         (print-length nil))
     (prin1 form))
(let ((email "me@gmail.com") (smtp-server "smtp.gmail.com") (smtp-port 587) (imap-server "imap.gmail.com") (imap-port 993)) (setf gnus-select-method (\` (nnimap (\, email) (nnimap-address (\, imap-server)) (nnimap-server-port (\, imap-port)) (nnimap-stream ssl)))) (setf message-send-mail-function (quote smtpmail-send-it) smtpmail-starttls-credentials (\` (((\, smtp-server) (\, smtp-port) nil nil))) smtpmail-auth-credentials (\` (((\, smtp-server) (\, smtp-port) (\, email) nil))) smtpmail-default-smtp-server smtp-server smtpmail-smtp-server smtp-server smtpmail-smtp-service smtp-port gnus-ignored-newsgroups "^to\\.\\|^[0-9. ]+\\( \\|$\\)\\|^[\"]\"[#'()]") (setf user-mail-address email) (setf smtpmail-stream-type (quote starttls)))
(let
    ((email "me@gmail.com")
     (smtp-server "smtp.gmail.com")
     (smtp-port 587)
     (imap-server "imap.gmail.com")
     (imap-port 993))
  (setf gnus-select-method
    `(nnimap ... ... ... ...))
  (setf message-send-mail-function 'smtpmail-send-it smtpmail-starttls-credentials
    `(...)
    smtpmail-auth-credentials
    `(...)
    smtpmail-default-smtp-server smtp-server smtpmail-smtp-server smtp-server smtpmail-smtp-service ...)
  (setf user-mail-address email)
  (setf smtpmail-stream-type 'starttls))
10
  • Seems like an issue with eval-expression-print-level. Try setting it to nil; do you still get the same result? Apr 11 '17 at 17:35
  • I bound the form to a variable and inspected it with accessors in elisp: I can see the expected form values, which makes sense. But I've tried let-binding both eval-expression-print-level and eval-expression-print-length to nil, but I'm still getting the dots on (pp form)
    – erjoalgo
    Apr 11 '17 at 18:10
  • I've gone down all the way to (prin1 form), which is in C source, but (prin1 form) still produces the dots
    – erjoalgo
    Apr 11 '17 at 18:12
  • OK, pp uses prin1, so try binding print-level instead of eval-expression-print-level. Apr 11 '17 at 18:59
  • 1
    How are you printing the form? By eval-expression and seeing the results in the echo area? That's controlled by the eval-expression- vars. For general printing, print- vars are used directly. See related question. Apr 11 '17 at 19:18
1

Using setf instead of a let binding to set the value of print-level and print-depth worked, though I'm not sure I understand why:

(progn (setf print-level 2
            print-length 2)
          (pp `(deeply (nested (form (very (deeply (nested))))))))
(deeply
 (nested ...))

"(deeply\n (nested ...))\n"

Setting to nil:

(progn (setf print-level nil
            print-length nil)
          (pp `(deeply (nested (form (very (deeply (nested))))))))
(deeply
 (nested
  (form
   (very
    (deeply
     (nested))))))

"(deeply\n (nested\n  (form\n   (very\n    (deeply\n     (nested))))))\n"
2

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.