elisp

Emacs lisp evaluate variable in alist

穿精又带淫゛_ 提交于 2019-12-03 16:46:54
This is a follow-up question to Emacs Lisp: evaluate variable in alist .. I am trying to set default-frame-alist in my .emacs file. Consider, e.g. (setq default-frame-alist '((auto-lower . nil) (auto-raise . nil) (height . 41) (width . 80) (top . 1) (left . 1))) (I have omitted some values) This works fine.. Suppose now I want set the height according to another variable..Say, I stored the integer value 50 in the variable my-height .. How can I set height to the value of my-height ? I have tried (height . my-height) ``(height . ,my-height)` but neither works.. What am I missing here? You need

What are the new rules for variable scoping in Emacs 24?

左心房为你撑大大i 提交于 2019-12-03 16:30:14
问题 Emacs 24 now has lexically-scoped variables. It also still has dynamically-scoped variables, of course. Now that it has both, I'm quite confused about when a variable will have which kind of scope. There's a lexical-binding variable that controls when lexical binding is enabled, and I think I read something about defvar now declaring a dynamically-scoped variable, but in general I'm pretty lost. Is there a good explanation somewhere of Emacs 24's new scoping rules? Or put another way, when I

Getting Emacs to respect my default shell + options

巧了我就是萌 提交于 2019-12-03 16:14:25
问题 I'm trying to get my Emacs shell to mimic that of my standard terminal sessions. Basically I would like it to respect the same PATH as well as the command prompt. So far I have a few issues: PATH isn't found, below is the fix I'm using for that. I'm getting ascii color codes all over the place with another fix I tried. I have the following in my mwilliams.el file. The first few lines give me access to /usr/local/bin in M-x shell, which solves half the problem and the last few lines get me

Elisp: How to delete an element from an association list with string key

懵懂的女人 提交于 2019-12-03 15:41:17
问题 Now this works just fine: (setq al '((a . "1") (b . "2"))) (assq-delete-all 'a al) But I'm using strings as keys in my app: (setq al '(("a" . "foo") ("b" . "bar"))) And this fails to do anything: (assq-delete-all "a" al) I think that's because the string object instance is different (?) So how should I delete an element with a string key from an association list? Or should I give up and use symbols as keys instead, and convert them to strings when needed? 回答1: If you know there can only be a

Using multiple Python shells in Emacs 'python-mode' with Python or IPython

爷,独闯天下 提交于 2019-12-03 15:14:11
Is there a way to force a new instance of python-shell while running Emacs? It would be convenient when working on multiple projects with separate working directories (and different sets of modules). Any attempt to invoke python-shell will only pull up the current instance. You need to rename your original python-shell before opening up a new one. Use M - x rename-buffer . Daimrod Renaming the buffer doesn't work for me, but you can use the third parameter of run-python . M - : (run-python nil nil t) RET Since the binding to switch to the current buffer isn't really helpful you can rebound it

How to set a key binding to make Emacs as transparent/opaque as I want?

隐身守侯 提交于 2019-12-03 14:55:20
问题 I want to have a command in Emacs to make it as opaque/transparent as I want (refer to the fabulous question that pointed out that transparency is possible in Emacs, and the EmacsWiki page linked there which has the code I am using below). The EmacsWiki code sets "C-c t" to toggle the previously set transparency on and off: ;;(set-frame-parameter (selected-frame) 'alpha '(<active> [<inactive>])) (set-frame-parameter (selected-frame) 'alpha '(85 50)) (add-to-list 'default-frame-alist '(alpha

multi lines python indentation on emacs

我的未来我决定 提交于 2019-12-03 14:10:55
问题 Im an emacs newbie, I want emacs to be able to indent my code like this egg = spam.foooooo('vivivivivivivivivi')\ .foooooo('emacs', 'emacs', 'emacs', 'emacs') It's not possible to do this automatically by default (without manually inserting spaces or C-c >), since emacs always indents 4 spaces (unless Im splitting multiple arguments over multiple lines). Whats the best approach to do this? PS: If this is a bad idea (against PEP 8 or something) please do tell me 回答1: I agree with Aaron about

Higher-order functions in Elisp

佐手、 提交于 2019-12-03 12:38:24
I created a function that returns a function in Elisp: (defun singleton-set (elem) (defun f (n) (= n elem)) f) I try to run this in IELM, and it fails: ELISP> (singleton-set 5) *** Eval error *** Symbol's value as variable is void: f ELISP> ((singleton-set 5) 5) *** Eval error *** Invalid function: (singleton-set 5) Due to What is the difference between Lisp-1 and Lisp-2? i changed the code to (defun singleton-set (elem) (defun f (n) (= n elem)) #'f) And invocation to (funcall (singleton-set 5) 5) , but now the error is *** Eval error *** Symbol's value as variable is void: elem I understand

Programmatically selecting a region

雨燕双飞 提交于 2019-12-03 12:24:46
I want to perform the same action that one does by hitting C-Space + moving the arrow keys, but in elisp. Failing to find the right function (if they just were logically grouped in namespaces or somehow tagged...). Which one is it? You can translate keystrokes to elisp using C-h k key . You'll notice the elisp function for setting the mark set-mark-command , takes one non-optional argument. Emacs uses the special interactive function to allow elisp functions to be written naturally with arguments. This allows them to be generic and easy to reuse in other elisp programs, while still possible to

elisp: Is there a way to get the name of the current .el module (like __FILE__ in C)?

不羁的心 提交于 2019-12-03 12:14:15
At the top of my elisp module, I want to do something as simple as: (message (concat "Loading " (expand-file-name (current-elisp-module) "."))) You can use the variable load-file-name , which is set by the function load , documented as follows: Full name of file being loaded by `load'. As elaborated in the manual: When Emacs is in the process of loading a file, this variable’s value is the name of that file, as Emacs found it during the search described earlier in this section. Note: buffer-file-name as a routine does not work as you might expect it to. 来源: https://stackoverflow.com/questions