Questions tagged [symbols]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
16
votes
3answers
2k views

How to create :keywords?

Q: How does one create and use :keywords? Consider a (naive, apparently) attempt to access the following toy alist: (setf alist '((:key-1 "Key no. 1") (:key-2 "Key no. 2"))) (assq :...
16
votes
3answers
3k views

Exporting unicode characters to pdf using latex from org mode

Hello Good people of Emacs! I'm having trouble exporting unicode math symbols from buffer (org-mode) to pdf file. 1. Problem Description: Symbols are inserted to the buffer as unicode characters (...
13
votes
4answers
3k views

What does `symbol-value` do?

The docs made me no wiser: This function returns the value stored in symbol's value cell. This is where the variable's current (dynamic) value is stored. If the variable has no local binding, ...
7
votes
2answers
187 views

When to use symbol properties?

Let's say I need to associate symbols with directories, and this will only need to be done for a small number of boundp symbols. The way I see it, there are two easy ways to do that: Store this ...
7
votes
1answer
276 views

Understanding uninterned symbols and macro expansion?

I want to demonstrate my lack of knowledge with an example. Using the following two macro defintions, (defmacro for (var from init to final do &rest body) "Execute a simple for loop: (for i ...
6
votes
3answers
271 views

How to use keyword symbols in Emacs Lisp?

According to Symbol Type A symbol whose name starts with a colon (‘:’) is called a keyword symbol. These symbols automatically act as constants, and are normally used only by comparing an unknown ...
6
votes
1answer
1k views

Function naming with forward slash?

I see this elisp code (Bernt Hansen): (defun bh/hide-other () (interactive) (save-excursion (org-back-to-heading 'invisible-ok) (hide-other) (org-cycle) (org-cycle) (org-cycle)...
5
votes
2answers
2k views

Naming convention for variable and function names

When programming in Emacs Lisp, should variable and function names always be lower case? According to The Emacs Lisp Style Guide they should use "lisp-case", but what is that? In Emacs Lisp manual the ...
5
votes
2answers
239 views

How to make (make-symbol “foo”) (make-symbol “foo”) equal?

I'm curious why: (equal (make-symbol "foo") (make-symbol "foo")) ends up beeing nil. While (equal 'foo 'foo) is t. Do i have a misconception of symbols? Aren't they just strings without double-...
5
votes
2answers
531 views

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

I want a complete list of things that works with thing-at-point. The documentation states: Possibilities include `symbol`, `list`, `sexp`, `defun`, `filename`, `url`, `email`, `word`, `sentence`, `...
4
votes
1answer
54 views

Why requiring fails with dynamic symbols?

I just encountered this behavior of Emacs. This works: (require 'test) But this doesn't (require (make-symbol "test")) Why is that and can I workaround it somehow?
4
votes
1answer
121 views

Certain symbols resulting in really tall line (and cursor)

This one is honestly a bit of a mystery for me. The strange behavior is caused by the lambda symbol: the line goes to normal height if I remove the lambda. How can I get Emacs to display such ...
3
votes
1answer
93 views

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

In the dash library I noticed the use of make-symbol to avoid symbol conflicts during macro expansion. (defmacro --filter (form list) "Anaphoric form of `-filter'. See also: `--remove'." (declare ...
2
votes
2answers
81 views

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

What's the most reliable way to get the start and end positions of the symbol at the cursor location (point)?
2
votes
1answer
158 views

Why is function defined by defun not bound

intro Sometimes I want to generate a function programmatically as opposed to defining one with defun. You may wondering why I'd want to do this. Well, it's complicated but just bear with me for a ...
2
votes
1answer
122 views

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

I am trying to create a global variable which name is contained in another variable, using defvar: (let ((var-name "my-test-var")) ;;(defvar (intern var-name) "some value") (defvar (make-symbol ...
2
votes
3answers
600 views

Is there a way to underline symbol under cursor?

I want to highlight somehow symbol under cursor, is there a way to customize font for that current symbol? Ideally I want to add underline with some color to it, or maybe change bg color of text, is ...
2
votes
1answer
147 views

How to prettify symbols inside comments?

I'm using prettify-symbol mode together with Pragmata Pro.el. Ligatures work perfectly fine in the source code but for some reason with comments they don't. I think I'm missing something since it's ...
2
votes
1answer
232 views

Mode local variables

I frequently use file-local variables, but after writing some minor modes I find the need to implement mode-based behavior. Let's say I want to define a variable errors-list-regexp that varies ...
2
votes
0answers
36 views

What is the flying trashcan icon replacing colons in Python buffers?

There is a strange icon appearing in place of colons (:) in my Python buffers. I cannot identify it easily using C-x = or any other command to inspect the character at the point because the icon ...
2
votes
0answers
407 views

In Emacs Lisp, how to convert roman numerals to an integer?

In Emacs Lisp, how to write an Emacs Lisp function to convert a natural number from roman numerals representation to the equivalent Emacs Lisp integer value? The Emacs Lisp function should be callable ...
1
vote
1answer
73 views

Difference between (quote string) and “string”

Experiment on interative ielm ELISP> (print 'list) list list ELISP> (print "list") "list" "list" Any differences with the two results? by the way, one extra times printed.
1
vote
1answer
100 views

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

Does Emacs have a way to set buffer-local properties on symbols? It's well-known that there are buffer-local variables. But a property belongs to a symbol, not to a variable. Hence, if I have ...
1
vote
1answer
87 views

practical relevance of storing value and function into one symbol

With Emacs Lisp it is possible to store a value and a function within the same symbol. (setq foo 6) (defun foo () (message "blah %d" foo))) Then you can do: (symbol-function 'foo) which returns the ...
1
vote
1answer
40 views

Modify face by its string name

In my config file i have the following lines to fix faces for Scala-mode: (make-face-bold scala-font-lock:lazy-face) (make-face-bold scala-font-lock:final-face) (make-face-bold scala-font-lock:...
1
vote
2answers
77 views

Unquoting a variable name (to implement variable pointers)

I know that if I have a variable with a function name, I can call it using funcall, like this (setq func-ref 'my-func) (funcall func-ref) I am wondering if there's a similar functionality for ...
1
vote
1answer
22 views

Wrong type argument: symbolp, 10

I would like create function that ask me how length I want the Pomodoro but it say wrong type argument. (defun changePomoLength () (interactive) (set-variable org-pomodoro-length (read-string "...
1
vote
1answer
30 views

What is the data-type for :symbol?

When looking at 'Face attributes' in emacs you have keywords like :family, :height, :weight etc. When using use-package you have keywords like :ensure, :init, :config etc. What are the terms for ...
1
vote
1answer
48 views

How to create a function with a computed name?

Let's suppose I have a string "foo" and want to create a function that would be an equivalent of (defun foo (...) ...). Is there a nice way to do it? I played with make-symbol and fset, but could ...
1
vote
1answer
49 views

how to convert “foobar?” into 'foobar?

I'm trying to turn a string containing a question mark into the corresponding symbol but: (intern "foobar?") returns 'foobar\? How can i do the same thing without the backslash? Also i'm interested ...
1
vote
2answers
95 views

Deleting whole variable name on M-backspace

Is there a way to configure emacs, so that when I hit M-backspace it would actually remove the whole variable? If I have a variable like my_dummy_variable I need to hit M-backspace three times in ...
1
vote
2answers
84 views

How to copy the symbol name at point?

I want to copy the name of the symbol at point, without using the mouse. (global-set-key (kbd "C-s C-c") '<copy_word>) Possible word marking as i-search does on the following example usage (...
1
vote
2answers
111 views

How to compare an item against others, that's compatible with string-equal?

When comparing the last-command against multiple possible strings, it doesn't seem possible to use the member function. Is there a way to simplify this using something like member? (when (or (...
1
vote
1answer
131 views

major-mode as argument to string-match vs string-equal

Why is (string-match "lisp" major-mode) not working, while (string-equal "lisp-interaction-mode" major-mode) is working? string-match results in debugger message: (wrong-type-argument stringp lisp-...
1
vote
1answer
22 views

Display abbreviated form of a function name?

I've seen videos where someone an elisp function call like (so-and-so/do-stuff) But were able to shorted the displayed function name to something like (so/do-stuff) How do they do that? I'd like ...
1
vote
1answer
223 views

How to fix Warning: assignment to free (local) variable in lambda function

The byte compiler just gave me this message 1103:24:Warning: assignment to free variable `orig-win-config on this bit of code: ;; create window config store and restore functions ;; credit to @...
1
vote
1answer
33 views

How to access variables/lists by the strings of their names, prompted interactively

I have a question about how to use interactive to allow the user to identify a desired list element to output. Let's say I have a variable x assigned to a list structured like this: (setq x '((y ("...
1
vote
1answer
58 views

How can I set the global value of a symbol created from a string?

I'm trying to make this little convenience function work: (defun my-make-hook (when procedure) (let ((hook-symbol (intern (concat (substring (symbol-name when) 1)...
1
vote
1answer
2k views

How to match the function name in a function call?

I am trying to extract the function name from a function call. For example: (let ((str "(test-func")) (if (string-match "^(\\s_+" str) (message "ok") (message "no match"))) But this ...
1
vote
0answers
12 views

symbol-name without adding to obarray

I found out that querying a symbol's name using symbol-name adds the symbol to obarray. (intern-soft "random-name") ; gives nil (symbol-name 'random-name) ; adds random-name to obarray, ...
0
votes
2answers
413 views

how to correctly pass around function as parameters?

I have a working snippet that advices both kill-buffer and kill-this-buffer to not kill the scratch buffer: (defun ninrod/scratch-bodyguard (buffer-assassin &rest arguments) (let ((buffer-...
0
votes
2answers
354 views

How to use xref-find-references on Elisp files without “No references found for” errors

I am using GNU Emacs 26.3 on Ubuntu 19.10. I have a directory full of Emacs Lisp files with the .el file extension. All of them are loaded into the currently running Emacs. I can open up one of ...
0
votes
1answer
93 views

Why would `symbol-name' return a fontified string?

I've got a weird bug in a GraphQL encoder I'm writing that I've tracked down to one form: (symbol-name 'world) ;; yields #("world" 0 5 (fontified t)) I can reproduce the issue in a *scratch* ...
0
votes
1answer
53 views

If a function is passed as an argument to another function, is the first function's name accessible?

I have some code that takes as an argument a function: (defun message-name (fn) ) I would like to be able to, if the function has a name, message it. For example, if called this way: (message-...
0
votes
1answer
1k views

Symbol's function definition is void on built-in variables?

For some reason I am getting errors for built-in variables that are available in the documentation. For instance, evaluating in the scratch buffer the following all return: Symbol's function ...
0
votes
0answers
43 views

How to extract symbols from an elisp buffer?

While I could parse the elisp myself, is there a way to extract symbols from an elisp buffer? That is, variable names, macros & functions - not part of strings.
0
votes
1answer
158 views

Wrong type argument: symbolp, possible mismatched parenteses in .spacemacs

I am trying to apply a fix to make it easier to change todo status in org mode. The code is the following: '( (org :variables org-want-todo-bindings t) ) from https://github.com/syl20bnr/...
0
votes
0answers
43 views

Is there a canonical way to convert a keyword to a symbol with no :?

I want to convert keywords, e.g. :some-key to a plain symbol like some-key. I currently do this with: (intern-soft (substring (symbol-name :some-key) 1)) Is there a better way?