elisp

C++11 mode or settings for emacs?

家住魔仙堡 提交于 2019-12-18 10:07:25
问题 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? 回答1: I've checked trunk version, cc-mode hasn't been updated yet, and AFAIK there's no alternative.

How to live with Emacs Lisp dynamic scoping?

我怕爱的太早我们不能终老 提交于 2019-12-18 10:03:57
问题 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

Auto install emacs packages with MELPA

十年热恋 提交于 2019-12-18 10:02:36
问题 I want to declare all packages that I want to use in emacs in a init.el file. I wonder if its possible to load the missing packages with e.g. MELPA when I startup emacs without going through the list and mark the ones I want to install? 回答1: New answer: While my original answer is still valid, I now use the method suggested by Jordon. use-package is a fantastic tool for tidy Emacs configurations. In fact, I was already using it for clean package loading when I wrote my original answer. At

How to Create a Temporary Function in Emacs Lisp

Deadly 提交于 2019-12-18 03:49:41
问题 I'm making some tedious calls to a bunch of functions, but the parameters will be determined at runtime. I wrote a simple function to keep my code DRY but giving it a name is unnecessary. I don't use this function anywhere else. I'm trying to do it the way I would in Scheme, but I get a void-function error: (let ((do-work (lambda (x y z) (do-x x) (do-y y) ;; etc ))) (cond (test-1 (do-work 'a 'b 'c)) (test-2 (do-work 'i 'j 'k)))) I could stick it all into an apply (e.g., (apply (lambda ...)

Using Emacs to indent (shift 4) code

二次信任 提交于 2019-12-18 03:29:30
问题 I edit my StackOverflow answers and questions with ViewSourceWith and Emacs. Often, I include code and StackOverflow formatting rules say that it must be indented by four spaces to be recognized as such. Doing it by hand or even with macros is painful. I searched in SO's previous postings but found nothing. Starting from the Python mode, I wrote: (defun text-shift-region (start end count) "Indent lines from START to END by COUNT spaces." (save-excursion (goto-char end) (beginning-of-line)

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

佐手、 提交于 2019-12-17 21:52:01
问题 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

Why am I getting “The authenticated user has not installed the app with client id” error when using the Google Drive API natively?

家住魔仙堡 提交于 2019-12-17 19:34:31
问题 I'm working on a Google Drive interface for Emacs. The concept is that Emacs could provide a platform-agnostic way to load, modify and save text documents stored in Google Drive. I've registered my app and can authenticate with OAuth2 and get a file listing with the Docs List API, but when I try to execute an Insert with the Google Drive API, I see an error: "The authenticated user has not installed the app with client id ..." Reading further, it seems I need to publish my Emacs application

Match regular expression as keyword in define-generic-mode

半世苍凉 提交于 2019-12-17 19:25:37
问题 I'm trying to write a new mode for emacs, using define-generic-mode. I've found a few tutorials which show how you can add keywords (as strings) which will then be highlighted. Is it possible to give define-generic-mode a regular expression so that it can then highlight anything that matches that as a keyword? I'd like to have a mode in which anything matching a date in the form 15/01/09 is displayed in a different font (preferably underlined, but I'll accept a different colour). Any ideas?

How to write a key bindings in emacs for easy repeat?

余生颓废 提交于 2019-12-17 18:57:30
问题 Let's say I bind the key to a certain function as follows: (global-set-key (kbd "C-c =") 'function-foo) Now, I want the key binding to work as: After I press C-c = for the first time, if I want to repeat the function-foo, I don't need to press C-c again, but simply repeat pressing = . Then, after I call the function-foo for enough times, I can just press keys other than = (or explicitly press C-g ) to quit. How to do this? 回答1: This may be the thing you are looking for: (defun function-foo ()

show org-mode outline up to a certain heading level

廉价感情. 提交于 2019-12-17 18:37:06
问题 I'm making an outline for my thesis using org-mode, and I'd like to show all headings up to a certain level (e.g. all level-1 and level-2 headings). I haven't found anything about that in the org-mode manual. Cycling shows either only level-1 headings, or all headings, which is too much information in my outline right now. Thanks, daniel. Update: I found a workaround for his: set the variable org-cycle-max-level. This is a global setting, though. 回答1: Just stumbled on this question. One year