Emacs Lisp: difference between (function (lambda …)) and (lambda …)?

What is the difference between (function (lambda …)) and (lambda …) and ‘(lambda …) ? It seems three are interchangeable in a lot of cases. Answer They are pretty interchangeable. The answer is that function enables the lambda to be byte compiled, whereas the other two do not (and are equivalent). Note: this does not … Read more

Check if current Emacs buffer contains a string

I have a buffer open in emacs. I want a function that will return t if the current buffer contains the string, otherwise it returns nil. (defun buffer-contains-substring (string) … ) Answer This is careful to not change where you are, or damage any match data. (defun buffer-contains-substring (string) (save-excursion (save-match-data (goto-char (point-min)) (search-forward string … Read more

How can I set environment variables to a buffer-local scope in emacs

In Emacs, I want to vary the values of my environment variables in different buffers. My emacs environment depends on environment variables (flymake, compile etc), however I want to be able to be able to have multiple projects open at once in one emacs session but these projects might have conflicting environments. For example something … Read more

What does regex [*\f]+ mean?

In the org-mode the outline-regexp variable is set to “[*\f]+”. I am not able to figure out what it stands for, referred this without success. Edit:- [*\f]+ changed to “[*\f]+” Answer The default value matches asterisks and page breaks: “[*\f]+” http://www.emacswiki.org/emacs/OutlineMode#toc2 AttributionSource : Link , Question Author : Talespin_Kit , Answer Author : bob

set the evil shift width to the buffer-local indentation in emacs

I use evil, which got (defcustom evil-shift-width 4 “The offset used by \\<evil-normal-state-map>\\[evil-shift-right] \ and \\[evil-shift-left].” :type ‘integer :group ‘evil) I’d like to set evil-shift-width to the buffer-local indent width (the variable indent). (add-hook ‘after-change-major-mode-hook (function (lambda () (setq evil-shift-width indent)))) What did I miss? Answer Without more information, I believe I understand the problem … Read more