elisp

Parsing in Emacs Lisp

为君一笑 提交于 2019-11-29 22:38:29
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 above int has value "1, 2, 3, ...", string "and, or, then, when" and text "Lorem ..." (excluding the

wrong type argument: stringp, nil

南笙酒味 提交于 2019-11-29 22:19:26
Before now I've just been cutting and pasting code into my .emacs file, but then I decided to add some maven functionality to emacs. Now, I don't see how I was able to mess this up, but last night I kept getting the error I put in the title when I run M-x jarl-mvn-exec. I slept on it, and came back the next day but I'm still not getting anywhere. (defun jarl-get-pom () (concat (locate-dominating-file (buffer-file-name (current-buffer)) "pom.xml") "pom.xml")) (defun jarl-visit-pom () (interactive) (find-file (jarl-get-pom))) (defun jarl-mvn-exec () (interactive) (switch-to-buffer (get-buffer

Command to clear shell while using emacs shell

社会主义新天地 提交于 2019-11-29 21:11:54
Is there a builtin command to clear shell while using shell in emacs? If not, is there an elisp function to achieve the same? 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 bottom of the buffer. When it stops at the top, the buffer looks like it's been cleared, although all the

How can I emulate Vim's * search in GNU Emacs?

天大地大妈咪最大 提交于 2019-11-29 20:56:31
In Vim the * key in normal mode searches for the word under the cursor. In GNU Emacs the closest native equivalent would be: C-s C-w But that isn't quite the same. It opens up the incremental search mini buffer and copies from the cursor in the current buffer to the end of the word. In Vim you'd search for the whole word, even if you are in the middle of the word when you press *. I've cooked up a bit of elisp to do something similar: (defun find-word-under-cursor (arg) (interactive "p") (if (looking-at "\\<") () (re-search-backward "\\<" (point-min))) (isearch-forward)) That trots backwards

Tips for profiling misbehaving Emacs Lisp?

佐手、 提交于 2019-11-29 20:08: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 I am, commenting out various things I've added recently, restarting emacs, trying to narrow down the

How to live with Emacs Lisp dynamic scoping?

雨燕双飞 提交于 2019-11-29 19:50:33
I've learned Clojure previously and really like the language. I also love Emacs and have hacked some simple stuff with Emacs Lisp. There is one thing which prevents me mentally from doing anything more substantial with Elisp though. It's the concept of dynamic scoping. I'm just scared of it since it's so alien to me and smells like semi-global variables. So with variable declarations I don't know which things are safe to do and which are dangerous. From what I've understood, variables set with setq fall under dynamic scoping (is that right?) What about let variables? Somewhere I've read that

C++11 mode or settings for emacs?

旧城冷巷雨未停 提交于 2019-11-29 19:44:16
I'm running Emacs 23.3.1 (Ubuntu, Oneiric package) and emacs doesn't appear to understand any of the new C++11 keywords, constexpr, thread_local, etc. Also it doesn't understand that '>>' is now permitted in template parameters, or the new 'enum class' syntax. Is there an updated or alternative module somewhere? Or failing that, some settings to make emacs more C++11 friendly in the mean time? I've checked trunk version, cc-mode hasn't been updated yet, and AFAIK there's no alternative. If you really want it, but don't want to get your hands dirty, you should pay someone to implement it for

Emacs font lock mode: provide a custom color instead of a face

筅森魡賤 提交于 2019-11-29 19:07:04
问题 On this page discussing font lock mode, an example is provided which highlights a custom pattern: (add-hook 'c-mode-hook (lambda () (font-lock-add-keywords nil '(("\\<\\(FIXME\\):" 1 font-lock-warning-face t))))) Is there a way to provide a custom color instead of font-lock-warning-face and without defining a new custom face. I want to be able to write something like: (font-lock-add-keywords nil '(("\\<\\(FIXME\\):" 1 "Blue" t))) or an RGB color definition: (font-lock-add-keywords nil '(("\\<

How to change emacs config in Lisp In A Box

橙三吉。 提交于 2019-11-29 19:07:01
问题 I have been a programmer for a decade now, but I believe this is the first time I've ever asked a question on a forum. I just can't figure this out and can't find the answer already online. I am trying to turn on CUA mode so that emacs is more bearable for a windows user (normal copy paste functions). I am running Windows 7 and installed emacs through the Lisp In A Box package. I understand that I need to add a line to my .emacs file or init.el file. I'm not sure which, but I can't find

Close all buffers besides the current one in Emacs

回眸只為那壹抹淺笑 提交于 2019-11-29 18:58:54
How do I close all but the current buffer in Emacs? Similar to "Close other tabs" feature in modern web browsers? For a more manual approach, you can list all buffers with C-x C-b , mark buffers in the list for deletion with d , and then use x to remove them. I also recommend replacing list-buffers with the more advanced ibuffer: (global-set-key (kbd "C-x C-b") 'ibuffer) . The above will work with ibuffer, but you could also do this: m (mark the buffer you want to keep) t (toggle marks) D (kill all marked buffers) I also use this snippet from the Emacs Wiki, which would further streamline this