Hot answers tagged

16 votes
Accepted

What does `symbol-value` do?

You need it when, in Elisp code, you want to get the value of a symbol, that is, its value when considered as a variable. Keep in mind that an Elisp symbol has several characteristics/features: It ...
  • 71k
13 votes
Accepted

Exporting unicode characters to pdf using latex from org mode

You need the latex file to use \usepackage[utf8x]{inputenc} rather than the default \usepackage[utf8]{inputenc}. This works with standard (pdf)latex. For org export to generate this you have to set ...
  • 7,043
13 votes
Accepted

What does “:” mean in elisp?

It turns the symbol into a keyword. See chapter 12.2 Variables that Never Change in the Emacs Lisp manual. Keywords are frequently used to identify named arguments to Lisp functions and macros. When ...
  • 12.7k
12 votes
Accepted

Naming convention for variable and function names

There is no GNU Emacs convention wrt case for Emacs-Lisp function and variable names. (There can be any number of such "conventions" that anyone could come up with, of course.) The "Emacs Lisp Style ...
  • 71k
12 votes
Accepted

How to make (make-symbol "foo") (make-symbol "foo") equal?

Do i have a misconception of symbols? Aren't they just strings without double-quotes? You do indeed have a misconception. A symbol is a lisp object containing numerous properties (including its name,...
  • 44.3k
12 votes
Accepted

How to use keyword symbols in Emacs Lisp?

They are usually used as keys ("properties") in a property list. E.g the variable org-publish-project-alist contains one or more property lists with keys like :base-directory, :publishing-...
  • 21.3k
10 votes

Meaning of CRM column in buffer list from `C-x C-b`?

`C' shows `>' if you have marked the buffer to be displayed, `D' if you have marked it for deletion, and `.' for the buffer from which you came (current). `R' shows `%' if the ...
  • 71k
10 votes

What does `symbol-value` do?

(Doh, @Drew already put some of the following up. Anyway, here's some additional detail.) As the manual page on symbol components explains, there are four components (cells) to each symbol: its ...
  • 31.4k
9 votes
Accepted

How to create :keywords?

You are right that make-symbol will create a keyword that is not eq to any existing keyword, and intern might pollute the global obarray with the new symbol. In between those, you have intern-soft, ...
  • 5,924
8 votes
Accepted

Function naming with forward slash?

There's no name space in Emacs lisp, so people use various prefixes to avoid name clash. Section D.1 of Emacs lisp reference manual recommends using a short prefix followed by one or two hyphen(s): ...
  • 7,043
8 votes

What does `symbol-value` do?

Here's a bit of historical reference (I haven't been born yet when the described events took place, so maybe someone more knowledgeable will correct me. All this is from reading old articles and some ...
  • 11k
7 votes

What does `symbol-value` do?

Small demo: (setq v1 10) ;;10 v1 ;;10 (setq v2 'v1) ;;v1 v2 ;;v1 (symbol-value v2) ;;10
  • 13.6k
7 votes

How to create :keywords?

Perhaps I'm not understanding the question correctly. But if you want a keyword (i.e., you want to satisfy keywordp) then you want the symbol to be interned in the global obarray, obarray. It must ...
  • 71k
7 votes

When to use symbol properties?

It really depends on the use cases. Generally speaking, symbol properties are "low-level" / "internal" features and one should not use them for "user-level" stuff. However, there is a place for ...
  • 5,539
7 votes
Accepted

Difference between (quote string) and "string"

'list and "list" are different datatypes: ELISP> (type-of 'list) symbol ELISP> (type-of "list") string Note that they even show up differently in your example -- it's the difference between ...
  • 8,659
6 votes

How to make (make-symbol "foo") (make-symbol "foo") equal?

You're confusing make-symbol and intern. make-symbol is used specifically when you want such an equality not to hold.
  • 25.5k
6 votes
Accepted

(symbol-name sym) vs. (format "%s" sym)

If KEYWORD is indeed always a symbol (in particular a keyword symbol) then IMO there's no special reason to use format. But there's no special reason not to, either: "better readability" is ...
  • 71k
5 votes
Accepted

Understanding uninterned symbols and macro expansion?

As mentioned in the comments, you have to turn on this setting to see how macro-expansion works more precisely. Note that it only changes how macroexpand is displayed, the macros still work the same ...
  • 13.6k
5 votes

Exporting unicode characters to pdf using latex from org mode

You'd just need to load proper unicode support in LaTeX via unicode-math and fontspec. Then you'd need to compile with xelatex or lualatex. See the docstring of the following variables: org-latex-...
  • 2,652
5 votes

Naming convention for variable and function names

Nothing is set in stone or enforced. That said, I highly recommend the lower-case and hyphens style. The only relevant thing I've found is in custom.texi: As described in @ref{Commands}, each ...
  • 13.6k
5 votes
Accepted

how to correctly pass around function as parameters?

Don't quote buffer-assassin when passing it to ninrod--protection. In your advice-functions, buffer-assassin is a variable, the value of which is the originial function. When you pass it quoted, ...
  • 404
5 votes
Accepted

practical relevance of storing value and function into one symbol

Emacs Lisp is a Lisp 2, which means only just what you described: the same symbol can have separate values as (1) a variable and (2) a function. (We call only #1 the "value" of the symbol.) Some ...
  • 71k
5 votes

How can I get list of all things supported by thing-at-point?

Yes, sure - use mapatoms: (defun find-symbols-having-properties (properties) (let (ret) (mapatoms (lambda (s) (when (cl-loop for prop in properties ...
  • 5,539
5 votes

How to use keyword symbols in Emacs Lisp?

I think the documentation you've linked to is comprehensive on the matter of their value: In Emacs Lisp, certain symbols normally evaluate to themselves. These include nil and t, as well as any ...
  • 44.3k
5 votes

How to use keyword symbols in Emacs Lisp?

To add a tiny bit to what others have said - Think of keywords as constants like t and nil, whose values are themselves (symbols). That is, like t and nil they are self-evaluating. The general use ...
  • 71k
4 votes
Accepted

Modify face by its string name

(intern "name") returns the interned symbol name make-symbol returns a new uninterned symbol, which is entirely distinct from the symbol with the face properties. Refer to C-hig (elisp) Creating ...
  • 44.3k
4 votes
Accepted

Why requiring fails with dynamic symbols?

OK, it looks like the symbol needs to be "interned". http://www.gnu.org/software/emacs/manual/html_node/elisp/Creating-Symbols.html This works as expected: (require (intern "test"))
  • 243
4 votes
Accepted

What's the most reliable way to get the start and end positions of current symbol under cursor?

The thingatpt.el API works as follows: (thing-at-point 'symbol) ;=> foo (beginning-of-thing 'symbol) ;=> 42 (end-of-thing 'symbol) ;=> 45 (bounds-of-thing-at-point 'symbol) ;=> (42 . 45) ...
  • 21.3k
4 votes

How can I get list of all things supported by thing-at-point?

It's not enough to test for properties beginning-op, end-op, bounds-of-thing-at-point, and thing-at-point. A thing can instead be defined by property forward-op or by a forward- THING function. (And ...
  • 71k
4 votes
Accepted

How can I get the effect of buffer-local symbol plist property values?

I am certain that the answer is no, and that variables are the only kind of buffer-local bindings provided by elisp. (I'm sure one of the elisp language maintainers will correct me if I'm wrong about ...
  • 44.3k

Only top scored, non community-wiki answers of a minimum length are eligible