elisp

how to delete the repeat lines in emacs

丶灬走出姿态 提交于 2019-12-03 11:02:17
问题 I have a text with a lots of lines, my question is how to delete the repeat lines in emacs? using the command in emacs or elisp packages without external utils. for example: this is line a this is line b this is line a to remove the 3rd line (same as 1st line) this is line a this is line b 回答1: Put this code to your .emacs: (defun uniq-lines (beg end) "Unique lines in region. Called from a program, there are two arguments: BEG and END (region to sort)." (interactive "r") (save-excursion (save

emacs lisp call function with prefix argument programmatically

ぃ、小莉子 提交于 2019-12-03 10:30:18
问题 I want to call a function from some elisp code as if I had called it interactively with a prefix argument. Specifically, I want to call grep with a prefix. The closest I've gotten to making it work is using execute-extended-command, but that still requires that I type in the command I want to call with a prefix... ;; calls command with a prefix, but I have to type the command to be called... (global-set-key (kbd "C-c m g") (lambda () (interactive) (execute-extended-command t))) The

How to view history of various commands in Emacs

烂漫一生 提交于 2019-12-03 10:18:21
Commands entered after pressing M-x can be viewed using the up / down arrow keys. How can I get a list of all the commands including menu bar invocation, commands triggered using mouse clicks, etc. in Emacs? I've used mwe-log-commands to make screencasts. It shows events and the commands they trigger as you work in Emacs. command-log-mode I've just forked it and made it into a proper minor-mode and global-minor-mode along with some other improvements as command-log-mode . Give it a shot and file issues against me if the documentation is unclear or if you find any bugs. bos For a complete list

In Emacs, how do I display a message in the minibuffer with font face properties?

亡梦爱人 提交于 2019-12-03 10:01:53
I want to display a colored string of text in the minibuffer, but when I use the 'message' function, the text-properties of are stripped. Works for me: (message "%s" (propertize "foo" 'face '(:foreground "red"))) You probably had (message (propertize ...)) , which interprets the propertized string as a format control string, hence stripped of its properties. 来源: https://stackoverflow.com/questions/2742435/in-emacs-how-do-i-display-a-message-in-the-minibuffer-with-font-face-properties

Create aliases in emacs?

做~自己de王妃 提交于 2019-12-03 09:49:28
问题 I have a copy of emacs that I use on a couple of different (windows) computers from a thumb drive, and I am wondering if it is possible to create something that is sort of the equivalent of a bash alias or symlink within emacs? Something that I could use within find-file is the main thing that i'm looking for, so for example: C-f <some link> would take me somewhere. Currently I have to add a new defun every time i get to a new computer, which is just kind of a pain and I would swear i've seen

Maintaining Emacs autoload files for user-installed elisp?

孤街浪徒 提交于 2019-12-03 09:40:43
问题 Emacs has this seemingly very nice facility for building autoload files based on magic source code comments ("autoload cookies") of the form ;;;###autoload , which are to be placed on lines by themselves immediately above each definition to be autoloaded; see (elisp)Autoload. This would seem to be an ideal tool for maintaining autoloads for those little one-file packages that Emacs users inevitably end up installing in their profiles. There's just one small problem: this facility (in GNU

How do I get basic App<->Emacs integration?

喜夏-厌秋 提交于 2019-12-03 09:28:16
问题 There are a bunch of applications out there that integrate Emacs with external processes. GDB is one that comes to mind. I can control GDB from emacs and then get feedback on the screen. I'd like to do something in that direction with my application. Here's what I want: establish a connection between me and emacs. I'd probably start a new emacs process and slurp it into my GUI tell emacs to display a file. (easy with emacsclient) tell emacs to scroll to center on a particular line number and

difference between (defalias 'A (symbol-function 'B)) and (defalias 'A 'B)

跟風遠走 提交于 2019-12-03 08:26:09
问题 I was reading subr.el and saw this code: (defalias 'backward-delete-char 'delete-backward-char) (defalias 'search-forward-regexp (symbol-function 're-search-forward)) Interestingly, the first line doesn't use symbol-function while the second line does. The only difference I know of these two ways of using defalias is that the help for backward-delete-char (the first one) displays that it is an alias for delete-backward-char while the help for search-forward-regexp doesn't. Is there a case

Elisp List Contains a Value

半城伤御伤魂 提交于 2019-12-03 07:27:02
问题 How do you check, in elisp, if a list contains a value? so the following would return t: (contains 3 '(1 2 3)) but (contains 5 '(1 2 3)) would return nil. 回答1: The function you need is member For example: (member 3 '(1 2 3)) It will return the tail of list whose car is element . While this is not strictly t , any non-nil value is equivalent to true for a boolean operation. Also, member uses equal to test for equality, use memq for stricter equality (using eq ). 回答2: freiksenet's answer is

Creating a new buffer with text using EmacsClient

一个人想着一个人 提交于 2019-12-03 07:23:48
I have a program that can send text to any other program for further analysis (eg sed, grep, etc). I would like it to send the data to Emacs and do analysis there. How would I do that? EmacsClient takes a filename by default, this is a data string not a file and I really don't want to create and delete files just to send data to Emacs. EmacsClient has an "eval" command-line option that let's you execute lisp code instead of open files. Is there a simple lisp function that will open a new buffer with the given text? Edit: I'm looking for something like: emacsclientw.exe -eval (open-new-buffer