elisp

“Wrong type argument: commandp” error when binding a lambda to a key

北城以北 提交于 2019-11-26 15:36:49
问题 I am getting a "Wrong type argument: commandp, (lambda nil (forward-line 5))" here. (global-set-key [?\M-n] (lambda () (forward-line 5))) What is the error? I'm fairly sure it's simple & I'm missing something obvious. 回答1: global-set-key expects an interactive command. (lambda () (interactive) (forward-line 5)) ought to work. By the way, C-h f commandp is a pretty good starting point for errors like that. 回答2: The correct form should be this - (global-set-key (kbd "M-n") (lambda ()

Why does an elisp local variable keep its value in this case?

╄→гoц情女王★ 提交于 2019-11-26 15:27:47
Could someone explain to me what's going on in this very simple code snippet? (defun test-a () (let ((x '(nil))) (setcar x (cons 1 (car x))) x)) Upon a calling (test-a) for the first time, I get the expected result: ((1)) . But to my surprise, calling it once more, I get ((1 1)) , ((1 1 1)) and so on. Why is this happening? Am I wrong to expect (test-a) to always return ((1)) ? Also note that after re-evaluating the definition of test-a , the return result resets. Also consider that this function works as I expect: (defun test-b () (let ((x '(nil))) (setq x (cons (cons 1 (car x)) (cdr x)))))

Using tramp with EmacsW32 and cygwin, possible?

本小妞迷上赌 提交于 2019-11-26 12:45:38
问题 I have some trouble setting up Tramp with EmacsW32 and cygwin. I have configured emacs to use cygwin as shell using w32shell. I also set the HOME enviromental variable to c:/cygwin/home/myusername Problem is that tramp seems to hang and that no connection is made: \"Tramp waiting for prompts for the new shell\". I have tried to turn on debugging, but still only see this message. Looking forward to get some tips on this. Thank you. 回答1: Take note of the cygwin-related information on the emacs

Emacs - Error when calling (server-start)

懵懂的女人 提交于 2019-11-26 11:53:09
问题 I am currently using GNU Emacs 23.0.93.1 in Windows Vista SP1. In my .emacs file I make a call to (server-start) and that is causing an error with the message The directory ~/.emacs.d/server is unsafe . Has anyone seen this and know a fix or workaround? ... other than leaving server turned off ;) Here is the stack trace: Debugger entered--Lisp error: (error \"The directory ~/.emacs.d/server is unsafe\") signal(error (\"The directory ~/.emacs.d/server is unsafe\")) error(\"The directory %s is

How to achieve code folding effects in Emacs?

坚强是说给别人听的谎言 提交于 2019-11-26 11:44:54
问题 Whats the best way to achieve something like code folding, or the type of cycling that org-mode uses. What would be the best solution in elisp to create this type of behavior? EDIT: I\'m sorry I was not clear. I want to program something in elisp that does things very similar to code folding, or actually most like org-mode with the hierarchy that can be expanded. I am wondering the best way to achieve this affect. I think I have heard emacs overlays are a good solution, but I dont know. As

When should Emacs #'function syntax be used?

本秂侑毒 提交于 2019-11-26 11:01:56
问题 Basically, when should I use Emacs Lisp\'s function procedure? I haven\'t found any examples in which there\'s a difference in behavior if you pass functions as arguments \'like-this or #\'like-this . In fact, if I evaluate (eq \'goto-char #\'goto-char) it returns t . The Emacs Lisp code that I\'ve come across rarely uses function / #\' ; the authors just quote / \' everything. Example: (add-hook \'emacs-lisp-hook \'turn-on-eldoc-mode) However, I can find a few counterexamples. Here\'s one

What's in your .emacs?

落花浮王杯 提交于 2019-11-26 07:50:43
问题 I\'ve switched computers a few times recently, and somewhere along the way I lost my .emacs. I\'m trying to build it up again, but while I\'m at it, I thought I\'d pick up other good configurations that other people use. So, if you use Emacs, what\'s in your .emacs? Mine is pretty barren right now, containing only: Global font-lock-mode! (global-font-lock-mode 1) My personal preferences with respect to indentation, tabs, and spaces. Use cperl-mode instead of perl-mode. A shortcut for

Why does an elisp local variable keep its value in this case?

风格不统一 提交于 2019-11-26 03:43:47
问题 Could someone explain to me what\'s going on in this very simple code snippet? (defun test-a () (let ((x \'(nil))) (setcar x (cons 1 (car x))) x)) Upon a calling (test-a) for the first time, I get the expected result: ((1)) . But to my surprise, calling it once more, I get ((1 1)) , ((1 1 1)) and so on. Why is this happening? Am I wrong to expect (test-a) to always return ((1)) ? Also note that after re-evaluating the definition of test-a , the return result resets. Also consider that this