elisp

Parsing in Emacs Lisp

时光怂恿深爱的人放手 提交于 2019-11-28 19:20:07
问题 I'm writing a parser in Emacs Lisp. It's a parser for text files looking like this: rule: int: 1, 2, 3, ... string: and, or, then, when text: ---------- Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Pellentesque in tellus. In pharetra consequat augue. In congue. Curabitur pellentesque iaculis eros. Proin magna odio, posuere sed, commodo nec, varius nec, tortor. ---------- more: ... rule: ... I don't really care about the key (int, string, ...). I want the value. So for the file

Command to clear shell while using emacs shell

蹲街弑〆低调 提交于 2019-11-28 17:19:16
问题 Is there a builtin command to clear shell while using shell in emacs? If not, is there an elisp function to achieve the same? 回答1: Update February 2015 Just noticed that Emacs now (version 25+) has the command comint-clear-buffer , bound to C-c M-o by default, that does what we need here, and probably is preferable to the answers I originally posted below. Options to consider: C-l will recenter the buffer. Pressing it repeatedly cycles the buffer, so that point appears at the top, middle, or

Run elisp program without Emacs?

心不动则不痛 提交于 2019-11-28 17:13:26
问题 elisp is a good language, I find it can handle all kind of jobs, but can I use it like a shell script? i.e. execute some *.el files from the console, without launching Emacs. Or launch Emacs, but don't enter interactive mode. 回答1: You can most definitely run elisp scripts in Emacs without starting the editor interface. Here are the notes I've made/copied from a few extremely useful Q&As on the subject here at S.O. (and the following two in particular). Emacs shell scripts - how to put initial

How to maximize Emacs on Windows at startup?

╄→尐↘猪︶ㄣ 提交于 2019-11-28 17:11:49
This is driving me crazy: I simply want Emacs to maximize to whatever screen resolution I have at startup. Ideally I like a cross-platform (Windows & Linux) solution that works on any screen resolution, but I can't even get it to work on just Window XP with even hard-coded sizes. Here are what I tried: Setting the initial-frame-alist with appropriate height/width Setting the default-frame-alist (Windows specific stuff) Sending message to the emacs windows telling it to maximize via (w32-send-sys-command 61488) Tried this function which I found somewhere: (defun toggle-fullscreen () "toggles

How do I create an empty file in emacs?

纵然是瞬间 提交于 2019-11-28 16:57:11
How can I create an empty file from emacs, ideally from within a dired buffer? For example, I've just opened a Python module in dired mode, created a new directory, opened that in dired, and now need to add an empty __init__.py file in the directory. If I use C-x C-f __init__.py RET C-x C-s then emacs doesn't create the file because no changes have been made to it. I would have to type in the file, save it, delete my typing and then save it again for that to work. Thanks Here's an adaptation of dired-create-directory . It works the same way, so as well as a plain filename, you can also specify

How to find a bug in “.emacs” or “init.el”?

谁说我不能喝 提交于 2019-11-28 16:54:38
Sometimes when I open Emacs, Emacs initialization fail. That is because .emacs or init.el files have a bug. (My bugs often come from just mistyping.) I want to find the bug in .emacs or init.el . Is there any way to do this? Drew To find out what part of your init file ( ~/.emacs ) is causing the behavior you see, bisect your init file recursively : First comment-out half, to see which half is responsible, then 3/4, to see which quarter is responsible,... To comment out a region of text (e.g. succession of lines that you have selected), I recommend comment-region (which I bind to C-x C-; ).

How to force Emacs not to display buffer in a specific window?

佐手、 提交于 2019-11-28 16:44:55
My windows configuration looks like this: +----------+-----------+ | | | | | | | | | | | | | | | | +-----------+ | | | +----------+-----------+ And I use the lower right window for special displays (like help, completion etc.), but emacs insists on using that window when I call commands ( find-file-other-window , etc.) that use display-buffer , and resize that window as well. It's annoying... Is there a way that I can force emacs NOT to use that windows? I was thinking of advising display-buffer , but it's a function in c. Any thoughts on this? EDIT: Based heavily on Trey's answer, this is

How can I get Emacs to revert all unchanged buffers when switching branches in git?

梦想的初衷 提交于 2019-11-28 16:17:22
问题 Often, when I switch branches in git, if the files are open in emacs, then emacs asks if I want to revert them (as it thinks they've changed on disk) even though the contents are identical. Firstly I'd like to find a way for emacs to not ask me about it at all if the contents on disk are identical to those in the buffer. Secondly I'd like a command that reverted (without query) all my open buffers that have no unsaved changes, and queried me about those that do have unsaved changes.

Emacs comment/uncomment current line [duplicate]

我的未来我决定 提交于 2019-11-28 16:12:10
This question already has an answer here: Eclipse-like Line Commenting in Emacs 7 answers I know there's already an Emacs question on this, and that it was closed, but I find it quite relevant and important. Basically, I want to comment/uncomment the current line. I was expecting this to be fairly easy with a macro, but I found that it really isn't. If the current line is commented, uncomment. If it is uncommented, comment it. And I would also to comment out the whole line, not just from cursor position. I tried a macro like this: C-a 'comment-dwim But this only work to comment a line, not to

Tips for profiling misbehaving Emacs Lisp?

拜拜、爱过 提交于 2019-11-28 15:57:58
问题 I customize Emacs a lot. Recently, I added something to my .emacs configuration that sporadically pegs my CPU at 100%, but I really don't know what it is. If I press C-g a bunch of times, eventually I'll get a message below the minibuffer asking me if I want to auto save my files and then if I want to abort emacs entirely. If I keep saying no and keeping pressing C-g, eventually I can get back to running emacs as normal. An hour or so later it will happen again. I could keep going about like