Emacs View Mail: trouble using vm-imap-account-alist - emacs

I have a little problem with ViewMail. In a separate file I'm defining variables with the account information of my email accounts, something like this:
(setq secret-mail-account-list-1 "imap-ssl:imap.aaa.com:993:*:login:xxx#aaa.com:password")
;;; other email accounts are defined as well
I do this to keep my password away from being recorded by Mercurial.
Then, I do write this into vm-imap-account-alist in another file:
(setq vm-imap-account-alist
'(
(secret-mail-account-list-1 "aaamail")
;;; other email accounts are here
)
)
But, after starting ViewMail with AltXvmEnter↵ I get the following error:
vm-imap-parse-spec-to-list: Wrong type argument: sequencep, secret-mail-account-list-1
How do I set the string to a variable so it is of the correct type for vm-imap-parse-spec-to-list?

I presume you got this from the EmacsWiki page. It looks like you want to pass the value of secret-mail-account-list-1 to vm-imap-account-alist rather than the symbol itself. To do so, you need to
backquote the alist and unquote the symbol with a comma to get its value:
(setq vm-imap-account-alist
`((,secret-mail-account-list-1 "aaamail") ; notice ` and ,
;;; other email accounts are here
))
At any rate, it helps to explain your error message: it looks like vm-imap-parse-spec-to-list expects a sequence (hence sequencep) such as a string which it converts to a list. Symbols are not sequences, but the content of yours is.

Related

What do common lisp function/special form/macro/etc. names mean and where can I find this information?

When I was learning HTML it was very helpful for me to know that ol means ordered list, tr is table row, etc. Some of the lisp primitives/forms are easy: funcall should be function call, defmacro - define macro. Some are in the middle - incf is... increment... f??? But because common lisp is so old, this primitives/special forms/etc... don't seem to ring a bell. Can you guys, help me with figuring them out? And even more importantly: Where can I find an authoritative resource on learning the meaning/history behind each and every one of them? (I will accept an answer based on this second question)
The documentation doesn't help me too:
* (describe #'let)
#<CLOSURE (:SPECIAL LET) {10013DC6AB}>
[compiled closure]
Lambda-list: (&REST ARGS)
Derived type: (FUNCTION (&REST T) NIL)
Documentation:
T
Source file: SYS:SRC;COMPILER;INFO-FUNCTIONS.LISP
* (documentation 'let 'function)
"LET ({(var [value]) | var}*) declaration* form*
During evaluation of the FORMS, bind the VARS to the result of evaluating the
VALUE forms. The variables are bound in parallel after all of the VALUES forms
have been evaluated."
* (inspect 'let)
The object is a SYMBOL.
0. Name: "LET"
1. Package: #<PACKAGE "COMMON-LISP">
2. Value: "unbound"
3. Function: #<CLOSURE (:SPECIAL LET) {10013DC6AB}>
4. Plist: (SB-WALKER::WALKER-TEMPLATE SB-WALKER::WALK-LET)
What do the following lisp primitives/special forms/special operators/functions mean?
let, flet
progn
car
cdr
acc
setq, setf
incf
(write more in the comments so we can make a good list!)
let: LET variable-name be bound to a certain value
flet: LET Function-name be bound to a certain function
progn: execute a PROGram sequence and return the Nth value (the last value)
car: Contents of the Address Register (historic)
cdr: Contents of the Decrement Register (historic)
acc: ACCumulator
setq: SET Quote, a variant of the set function, where in setq the user doesn't quote the variable
setf: SET Function quoted, shorter name of the original name setfq. Here the function/place is not evaluated.
incf: INCrement Function quoted, similar to setf. Increments a place.
Other conventions:
Macros / Special Forms who change a place should have an f at the end: setf, psetf, incf, decf, ...
Macros who are DEFining something should have def or define in front: defun, defmethod, defclass, define-method-combination...
Functions who are destructive should have an n in front, for Non-consing: nreverse, ...
Predicates have a p or -p at the end: adjustable-array-p, alpha-char-p,...
special variables have * at the front and back: *standard-output*, ...
There are other naming conventions.
let: Well, that's a normal word, and is used like in maths ("let x = 3 in ...").
flet: I'd guess "function let", because that's what it does.
progn: This is probably related also to prog1 and prog2. I read is as "program whose nth form dictates the result value". The program has n forms, so it's the last one that forms the result value of the progn form.
car and cdr: "Contents address register" resp. "Contents decrement register". This is related to the IBM 704 which Lisp was originally implemented for.
setq: "set quote", originally an abbreviation for (set (quote *abc*) value).
setf: "set field", came up when lexical variables appeared. This is a good read on the set functions.
Where can I find an authoritative resource on learning the meaning/history behind each and every one of them?
The HyperSpec is a good place to start, and ultimately the ANSI standard. Though "Common Lisp The Language" could also shine some light on the history of some names.
(Oh, and you got defmacro wrong, that's "Definition for Mac, Read Only." ;) )

How to remove some link type in Emacs?

I made all URLs clickable by:
(define-globalized-minor-mode global-goto-address-mode goto-address-mode goto-address-mode)
(global-goto-address-mode)
However, when I have a shell command with "service:" substring, Emacs treats it as a link incorrectly. How can I remove that link type?
Emacs 27.1 makes this a bit more configurable via the two new variables:
goto-address-uri-schemes-ignored
goto-address-uri-schemes
You should set only one of the two and, per the docstrings, must do so before the goto-addr library is loaded. This is because the new variables are only intermediate values1 which are used when defining goto-address-url-regexp -- which (as before) is the only value which is ultimately used by the library.
If you wish to change the behaviour after loading goto-addr then you need to re-generate or otherwise set goto-address-url-regexp, exactly the same as in earlier versions. See my original answer for an example of doing this.
1 Specifically, goto-address-uri-schemes-ignored affects the default value of goto-address-uri-schemes, which in turn affects the default value of goto-address-url-regexp.
Try this:
(setq goto-address-url-regexp
(concat "\\<"
(regexp-opt (cl-delete-if
(lambda (x)
(member x '("mailto:" "data:" "service:")))
(copy-sequence thing-at-point-uri-schemes))
:paren)
thing-at-point-url-path-regexp))
This should also fix bugs in the original regexp, so it could match some new things as well, but probably nothing you're worried about ("svn+ssh://" and "bzr+ssh://" will match now, and a few others will be more constrained where dots are concerned. Basically the original code didn't regexp-quote the schemes!)
Note that "mailto:" and "data:" were being excluded in the original.

In Lisp, how do you get the value of an expression?

This will print data, but I want it to print show. I want to print the value, not the expression, how would I do it?
(defun display (x)
(list x))
(setq temp 'data)
(set temp 'show)
(display 'data)
what if u dont know if the variable is bound or not? i have to write a function that take a key and a value, if key does not exist, then i have to do setq key value, if the key already exist, then i would add the value to the key. In this case, if i do (storedata key value), if value have not been bounded, i get an unbound error, how would i handle this case?
for example, if there is no mydata and i do (storedata value mydata) then mydata would become (value), now if i do (storedata value2 mydata) then mydata becomes (value value2).
Quoting a list or a symbol in Lisp with ' is exactly equivalent to using the special form (quote ...). It's specifically for making the quoted thing not get evaluated. 'data in Lisp code or typed into the REPL is the same thing as (quote data), and evaluates to the symbol data.
data without the quote evaluates to the value of the variable data in the current scope. So, at the REPL:
[1]> (setq data 14)
14
[2]> data
14
The first expression also evaluates to 14 because setq returns the value of the bound variable (in this respect acting like the assignment operator = in C).
What you've done in the above code is to set the variable named temp to contain the symbol data, then, by using set (without the setq), set the variable named data to the symbol show. This is a bit similar to using soft references in Perl (for example), but I don't think it's particularly widely used or advisable as a Lisp technique.
By the way, your display procedure is probably not doing what you think either: it returns a single element list of whatever you pass to it. The fact that the value gets printed when you type it into the REPL is just because the value of any expression gets printed at the REPL. To display a value in a program you might use print or maybe format. (I'm assuming you're using Common Lisp, since it's obviously not Scheme, but maybe it's some other Lisp variety, in which case that link won't help.)
You are quoting data. If you want it to be evaluated you should just call
(display data)

Variable passed to macro gets resolved in wrong namespace?

The Noir macro defpage is giving me a little bit of trouble. I am trying to construct a call similar to this:
(defpage [:post "some/url"] [data]
;; some stuff...
)
However, instead of using the keyword :post I would like to use a variable, like this:
(def my-method :post)
(defpage [my-method "some/url"] [data]
;; some stuff...
)
The problem is that when the macro expands, it wants to resolve the variable my-method in the compojure.core namespace instead of my own, giving me the error:
No such var: compojure.core/MY-METHOD
How can I force my-method to resolve in the current context?
I guess this is a similar problem to: How can I apply clojure's doc function to a sequence of functions
A macro can do whatever it wants with its args, so passing a naked symbol in can result in unpredictable results.
A way to solve it, but it ain't pretty:
(eval (list 'defpage (vector my-method "some/url") '[data]
; some stuff
))
Notice that my-method is not a literal here, so it gets resolved and evaluated in our own namespace first, before going into eval.
It seems, that noir is not meant to be used this way, because it takes the method argument and transforms it to the symbol in compojure.core (see https://github.com/ibdknox/noir/blob/master/src/noir/core.clj#L36). It means, that it doesn't expect a variable in this place, only literals. So I don't think you can do anything about that, except post an issue to noir...
If we look through noir/core.clj file (source), find parse-route function and reason what it does with its method argument (it is called action there), we could find that method keyword is converted to string, uppercased and resolved in compojure.core namespace. All this is done during macro expansion time. So it is not possible to use variable instead of keyword without altering noir code.
What about passing my-method along with namespace it is in:
(defpage [myns/my-method "some/url"] [data]
;;
)

defaultcontent.el - ##LISP tag - read-closest-sexp?

I started using defaultcontent.el to fill newly-created buffers with content.
Apparently this module is not widely used. I think there are 3 people including me and the author who use it, because when I do a search on it, my published emacs.el comes up as the first hit.
Despite that, I find it useful. I specify a template for each file type, and every time I create a new file of that type (or extension), it gets filled with the content in the template file. The template supports well-known tags set off with "##", that get substituted at runtime:
AUTHOR inserts the user name;
DATE (obvious);
FILENAME, inserts the name of the file being created;
ENV(xxx), inserts the value of the environment variable xxx;
and there are a few other tags.
eg, whereever ##AUTHOR## is found in the template, it gets replaced with your user name at runtime in the newly created file.
ok, this isn't an advertisement for defaultcontent.el, I just thought I'd explain it a little.
here's the question.
One of the well-known tags in the template is LISP - it purports to run arbitrary elisp code to generate content to insert into the new buffer. (usage: ##LISP(lisp content here)##). It depends on a function read-closest-sexp, which I guess would just read the sexp at point.
I can't find this function. It's not included in defaultcontent.el, and I'm not up enough on elisp to create it easily. I looked in emacs-lisp\lisp.el for hints but it seemed non obvious.
Question: how can I read the sexp at point into a variable?
I'm guessing this is 2 lines in elisp...
Try thing-at-point:
(require 'thingatpt)
(let ((sexp (thing-at-point 'sexp)))
(do-something-with sexp))
Indeed two lines if you ignore the do-something :)