elisp

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

余生颓废 提交于 2020-01-22 15:14:25
问题 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. 回答1: You need to rename your original python-shell before opening up a new one. Use M - x rename-buffer . 回答2: Renaming the buffer doesn't work for me, but you can use the third parameter of run-python . M - : (run-python

Elisp: How to save data in a file?

☆樱花仙子☆ 提交于 2020-01-22 07:14:20
问题 I want to save data to a file in my elisp program. I have a multi-dimensional list that I want to save to a file, so I can restore it the next time my program runs. What's the easiest / best way to do this? I realise, of course, that I can simply write my data to a buffer in a custom format and then save the buffer, but then I'd have to write a function to parse that data format when I want to restore it. I'd rather not have to do that. In Python, there's the Pickle module that lets you "dump

dired-read-file-name: pop-up dired mode to read-file-name

陌路散爱 提交于 2020-01-21 23:50:11
问题 Could anyone please give me a hand to briefly pop-up a dired buffer for the purposes of read-file-name : (defun dired-insert-file () (interactive) (setq filename (dired-read-file-name "~/Desktop")) (kill-buffer dired) (get-buffer-create "*foo*") (set-buffer "*foo*") (insert-file filename)) EDIT : Revised example: (require 'dired) (defvar open-with-variable nil) (defvar save-as-variable nil) (defvar save-as-buffer-filename nil) (defun dired-read-file-name (&optional directory) (let* ( output

dired-read-file-name: pop-up dired mode to read-file-name

♀尐吖头ヾ 提交于 2020-01-21 23:46:52
问题 Could anyone please give me a hand to briefly pop-up a dired buffer for the purposes of read-file-name : (defun dired-insert-file () (interactive) (setq filename (dired-read-file-name "~/Desktop")) (kill-buffer dired) (get-buffer-create "*foo*") (set-buffer "*foo*") (insert-file filename)) EDIT : Revised example: (require 'dired) (defvar open-with-variable nil) (defvar save-as-variable nil) (defvar save-as-buffer-filename nil) (defun dired-read-file-name (&optional directory) (let* ( output

Tell emacs to interpret words breaking them at newline and whitespace

感情迁移 提交于 2020-01-17 12:15:25
问题 I would like to tell emacs to break "words" when there is a whitespace or a newline (the one used in forward-word). If I use forward-word on this (the cursor is in the capital letter or with a _) _aaaa} {bbbb then I get aaaa} {bbbb_ Since I dislike this behaviour I tried remapping M-f with forward-whitespace. In the above case the cursors places between the two brackets, as I want, but in a case like this _aaaa-bbbb the cursor goes here after a forward-whitespace aaaa-bbbb_ so if I want to go

max-lisp-eval-depth to find sqrt-iter

北慕城南 提交于 2020-01-16 11:12:10
问题 I am working on SICP's exercise 1.6 which rewrite the demonstration case #+begin_src emacs-lisp :session sicp :results output (defun sqrt(x) (sqrt-iter 1.0 x)) (defun sqrt-iter(guess x) (if (good-enough-p guess x) guess (sqrt-iter (improve guess x) x))) (defun good-enough-p(guess x) (< (abs (- (square guess) x)) 0.001)) (defun improve(guess x) (average guess (/ x guess))) (defun average(x y) (/ (+ x y) 2)) #+end_src It works and get the output #+begin_src emacs-lisp :session sicp :lexical t

Narrow to subtree with org-velocity

只愿长相守 提交于 2020-01-15 12:15:47
问题 I would like to use org-velocity as my primary means of navigating large .org files but with the following changes: After running a search in org-velocity, I would like the buffer to automatically narrow to that subtree, once I make my selection. Org-velocity should run its search against the entire file, even if the buffer is narrowed. For part (1) I think something like this should work: (add-hook 'org-follow-link-hook (lambda () (org-narrow-to-subtree))) But this is not the right hook. Not

How to make Emacs lock-buffer fail when it cannot lock a file?

会有一股神秘感。 提交于 2020-01-14 13:06:28
问题 I want to some Emacs lisp to manipulate same file from different Emacs processes. So I wrote the following script to check how lock-buffer works. However, it stops when trying to lock the file by the second Emacs process ( find-and-lock-file $es2 /tmp/dummy ). I need to go to another terminal and send emacsclient --socket-name server-2 --eval '(kill-emacs)' to stop the Emacs process. Emacs prompts what to do for the file if I open an UI by emacsclient -t --socket-name server-2 , but I want to

Emacs lisp; how to make a string from a variable of any type?

倖福魔咒の 提交于 2020-01-14 10:12:44
问题 Like error messages for wrongly called functions show, eg.: (message (file-attributes ".")) Produces the message: "eval: Wrong type argument: stringp, ("/home14/tjones" 1 0 0 (20415 35598) (20211 19255) (20211 19255) 14 "lrwxrwxrwx" t ...)" How do you do this type of translation intentionally, eg.: (message (thing-to-string (file-attributes "."))) To message something like: ("/home14/tjones" 1 0 0 (20415 35598) (20211 19255) (20211 19255) 14 "lrwxrwxrwx" t ...) This is for debugging/info only

Why is there blank space where there ought be line numbers in Emacs?

点点圈 提交于 2020-01-13 19:03:33
问题 I'm using (global-linum-mode t) to present line numbers in Emacs. This works just fine up-until I use the ctrl + up / down commands ( forward-paragraph and backward-paragraph ) to navigate a buffer, at which point some line numbers are rendered incorrectly (see attached image). This occurs only when I use said commands to skip entire segments of code, and the issue immediately disappears (the line numbers are rendered correctly, that is) if I start navigating the buffer by other means. The