Hot answers tagged

14 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-...
NickD's user avatar
  • 29.2k
13 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 ...
Drew's user avatar
  • 77k
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 ...
JeanPierre's user avatar
  • 7,423
13 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,...
phils's user avatar
  • 50.4k
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 ...
db48x's user avatar
  • 17.6k
8 votes

When is the first element in the argument list regarded as a function symbol and when not?

the first element of a list is interpreted as a function symbol That's the most common case, but it isn't an absolute rule. First, you need to know that every symbol can have both a function meaning (...
Gilles 'SO- stop being evil''s user avatar
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 ...
zck's user avatar
  • 9,072
7 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 ...
phils's user avatar
  • 50.4k
7 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 ...
Drew's user avatar
  • 77k
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.
Stefan's user avatar
  • 26.3k
6 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 ...
Drew's user avatar
  • 77k
6 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) ...
wasamasa's user avatar
  • 22.1k
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 ...
Drew's user avatar
  • 77k
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, ...
ChrisR's user avatar
  • 404
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-...
rasmus's user avatar
  • 2,712
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 ...
abo-abo's user avatar
  • 14.1k
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 ...
sds's user avatar
  • 6,104
5 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 ...
phils's user avatar
  • 50.4k
5 votes
Accepted

How to insert mathematical symbols in emacs

You can set the insert method with M-x set-input-method RET tex. Then type \beta and watch it get converted. It can be toggled and set with C-\! Tested and confirmed that it compiles and renders ...
mcp's user avatar
  • 546
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 ...
phils's user avatar
  • 50.4k
4 votes
Accepted

Why does `make-symbol` work in macro expansion, just as `gensym` works?

It's not the same symbol, even though it has the same name. This returns (nil foo), because the interned symbol foo created by reading 'foo is not the same symbol as the uninterned symbol foo ...
Drew's user avatar
  • 77k
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 ...
Drew's user avatar
  • 77k
4 votes
Accepted

Why is function defined by defun not bound

If you assign a function to an uninterned symbol, then naturally you won't find that function on the interned symbol of that name -- they are two completely independent objects. Your void-defun is ...
phils's user avatar
  • 50.4k
4 votes

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

Is there a reason this is preferable to using symbol-name? No, I think it just comes down to style and context. E.g. I can imagine someone preferring to consistently use format everywhere, because ...
Basil's user avatar
  • 12.3k
4 votes

When is the first element in the argument list regarded as a function symbol and when not?

Lisp code and some Lisp data structures (lists, symbols, strings, vectors, etc.) can be the same thing. Lisp code is a Lisp data structure that's ready to be evaluated, that is, "run". Both ...
Drew's user avatar
  • 77k
3 votes
Accepted

How to use defvar with the symbol name in another variable?

It isn't equivalent. If you test the symbol of a defvar'd variable with special-variable-p you get t, however this is not the case for your code. This bit must be set for the variable to be usable ...
wasamasa's user avatar
  • 22.1k
3 votes
Accepted

What is the data-type for :symbol?

From the manual Section 9.2. "Symbol Components": Most symbols can have any Lisp object as a value, but certain special symbols have values that cannot be changed; these include nil and t, and any ...
Tobias's user avatar
  • 33.1k
3 votes
Accepted

How to create a function with a computed name?

Try this: (let ((name "foo")) (fset (intern name) (lambda (x) (* 2 x)))) (foo 21) ; 42 Brief explanation: (intern name) creates a symbol with the given name and adds it to the list of ...
Harald Hanche-Olsen's user avatar
3 votes
Accepted

How to prettify symbols inside comments?

When symbols are composed with prettify-symbols-mode is controlled by prettify-symbols-compose-predicate. By default this will only compose symbols if they are at a word boundary and not inside a ...
Prgrm.celeritas's user avatar

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