elisp

Python dictionary or map in elisp

余生颓废 提交于 2019-12-04 05:08:23
What is the equivalent of a python dictionary like {'a':1, 'b':2} in elisp? And again, does elisp have any map-reduce api? Association lists are the most commonly used associative containers in elisp. It is just a list of key-value cons cells like this ((key . value)) . You can use the assoc function to get a value corresponding to a key and rassoc to get a key with the required value. Elisp comes with the built-in function mapcar which does map, but AFAIK there is no good fold facility. You could emulate it using any of the looping facilities provided. However, the better solution is to use

Emacs: bulletproof up-list?

此生再无相见时 提交于 2019-12-04 04:26:42
问题 I'm getting up-list: Scan error: "Unbalanced parentheses" from this position: (foo "bar|") Snippet from up-list doc: This command assumes point is not in a string or comment. So this is the expected behavior. But I don't care. I just want to go upwards from a list. Could someone suggest an up-list clone that does the proper thing? I'm looking for something better than this naive code: (defun up-list-naive () (interactive) (while (not (ignore-errors (up-list) t)) (forward-char))) 回答1: EDIT:

Emacs / Magit — how to create and delete repositories on Github

左心房为你撑大大i 提交于 2019-12-04 04:23:53
问题 I am having trouble in Magit with step number 5 and step number 7 to create a new repository. If they exist, what are the interactive function equivalents (please) for steps 5 and 7? If there are no interactive equivalents, I guess I will need to write my own shell command functions -- unless, of course, someone would like to take a stab at them first. :) CREATE -- COMMAND-LINE RECIPE 1. $ touch README.md 2. $ /usr/local/git/bin/git init 3. $ /usr/local/git/bin/git add . 4. $ /usr/local/git

What is the role of the @ character in Emacs Lisp?

老子叫甜甜 提交于 2019-12-04 03:56:22
问题 As used for instance in this macro definition: (defmacro with-eval-after-load-feature (feature &rest body) (declare (indent 1) (debug t)) (let* ((feature (if (and (listp feature) (eq (car-safe feature) 'quote)) (cdr feature) feature)) (fs (if (listp feature) feature (list feature))) (form (or (and (eval '(eval-when (compile) (with-eval-after-load-feature-preload fs))) 'with-no-warnings) 'progn))) `(,form ,@(with-eval-after-load-feature-transform fs body)))) in this file. 回答1: It's used for

how to answer yes or no automatically in emacs

雨燕双飞 提交于 2019-12-04 03:52:37
I binded function semantic-symref to key C-c C-r like this: (global-set-key (kbd "C-c C-r") 'semantic-symref) everytime I pressed C-c C-r , it prompted: Find references for xxxxx? (y or n) How can I answer it automatically? I tryed using lambda function like this, but failed (global-set-key (kbd "C-c C-r") (lambda() (interactive) (semantic-symref "yes"))) The answer by @huitseeker is quite neat and effective. After four years, with flet and defadvice being obsolete, I wrote the following functions to answer yes automatically. Maybe it's useful for someone. (defun my/return-t (orig-fun &rest

elisp: call command on current file

房东的猫 提交于 2019-12-04 03:19:36
I want to set a key in emacs to perform a shell command on the file in the buffer, and revert the buffer without prompting. The shell command is: p4 edit 'currentfilename.ext' (global-set-key [\C-E] (funcall 'revert-buffer 1 1 1)) ;; my attempt above to call revert-buffer with a non-nil ;; argument (ignoring the shell command for now) -- get an init error: ;; Error in init file: error: "Buffer does not seem to be associated with any file" Completely new to elisp. From the emacs manual , here is the definition of revert-buffer: Command: revert-buffer &optional ignore-auto noconfirm preserve

Emacs/GDB: always display source in specific window with gdb-many-windows

喜夏-厌秋 提交于 2019-12-04 03:18:38
I use GDB in Emacs 24 with gdb-many-windows set to t , usually in its own frame. I like to have a separate editing frame. It looks like this (apologies for my crude ASCII diagram): +-------------+-------------+ | gdb | locals | +-------------+-------------+ | source | I/O | | | | +-------------+-------------+ | stack | breakpoints | +-------------+-------------+ This works pretty well except for one big problem. Whenever gdb needs to display a different source buffer, e.g., after up/down/step, it doesn't always show it in the "source" window. For example, if I have the same buffer open in a

How to create an empty file by elisp?

ぐ巨炮叔叔 提交于 2019-12-04 02:53:06
I set an explicit file to customization created via the UI. It's named custom.el . Currently, I use the followed snippets to create this file if not exist. (defconst custom-file (expand-file-name "custom.el" user-emacs-directory)) (unless (file-exists-p custom-file) (shell-command (concat "touch " custom-file))) There is an ugly shell-command touch in, any other elisp functions can do this? You can use (write-region "" nil custom-file) not sure that is the ideal solution. 来源: https://stackoverflow.com/questions/14071991/how-to-create-an-empty-file-by-elisp

Emacs: disable Ido completion in Tramp mode

老子叫甜甜 提交于 2019-12-04 02:37:32
I often use ido for auto-completion and tramp to access remote server via ssh. My .emacs includes the following lines: (require 'tramp) (setq tramp-default-method "ssh") (ido-mode 1) (setq ido-enable-flex-matching t) (setq ido-everywhere t) I want to disable Ido completion, when i'm browsing contents of remote server. Note that variable ido-enable-tramp-completion has nothing to do with my problem. Consider line /root@site.com#1234:/var/www/file.txt . I need Ido not to deduct the part after the colon (remote file path), i don't care about the part before the colon. I use ssh, and Ido makes

Shift arrow selection in emacs

假如想象 提交于 2019-12-04 02:31:09
问题 I'm using GNU Emacs 23.2.1 my init.el (cua-mode 1) (transient-mark-mode 1) (setq shift-select-mode t) (global-linum-mode 1) (show-paren-mode 1) (desktop-save-mode 1) So, instead of selection I get 2C on Shift =>, 2D on Shift <=, etc. How to solve this? P.S. cat -v for Shift <= ^[[1;2D cat -v for Shift => ^[[1;2C How I can map properly those keys to shift-left, shift-right corresponding? P.P.S. Sorry. I've forgot. I'm also using screen. den@playground:~/.emacs.den$ echo $TERM screen Solution: