Questions tagged [symbols]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
1
vote
1answer
35 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 ...
0
votes
1answer
31 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/...
1
vote
1answer
59 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 ...
1
vote
1answer
43 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 ...
5
votes
2answers
170 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-...
0
votes
1answer
74 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* ...
1
vote
1answer
50 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 ...
2
votes
2answers
57 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)?
1
vote
1answer
78 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 ...
1
vote
1answer
90 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-...
0
votes
0answers
37 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?
1
vote
1answer
56 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)...
0
votes
2answers
359 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-...
1
vote
3answers
466 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 ...
1
vote
1answer
20 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 ...
0
votes
1answer
51 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
644 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 ...
1
vote
1answer
126 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 @...
2
votes
0answers
303 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
37 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
88 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 ...
14
votes
3answers
2k 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 (...
7
votes
1answer
192 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
1answer
944 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)...
4
votes
1answer
53 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?
2
votes
1answer
183 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 ...
5
votes
2answers
1k 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 ...
12
votes
4answers
2k 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, ...
16
votes
3answers
1k 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 :...
1
vote
1answer
1k 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 ...
7
votes
2answers
170 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 ...
4
votes
1answer
118 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 ...