Skip to main content
15 votes

Meaning of period in (. 123)

It looks like Emacs simply reads (. 123) as 123, what happened? That's exactly what happened. To back it up with sources: if (ch == '.') { if (!NILP (tail)) XSETCDR (tail, read0 (...
wasamasa's user avatar
  • 22.4k
9 votes
Accepted

What does hash s indicate in lisp

That is a struct of elfeed-entry (defined by elfeed). The #s here means struct. The first one is for elfeed-entry, the second is for elfeed-ref. (cl-defstruct website name shortname url shorturl) (...
Kisaragi Hiu's user avatar
8 votes

How to read elisp file into s-expression?

This is a better approach I think. (with-current-buffer (find-file-noselect "foo.el") (goto-char (point-min)) (read (current-buffer))) If you want to wrap this as you describe below, and ...
John Kitchin's user avatar
  • 12.1k
6 votes
Accepted

How can I convert a string form of a list to an actual list?

ELISP> (read "(a b c)") (a b c) ELISP> (read "(9 . 3)") (9 . 3) If by (9 . 3) you mean you'd like a cons, then my answer would work. Note however if you actually would like ...
TerryTsao's user avatar
  • 1,236
5 votes
Accepted

How should you read a Lisp file as Lisp for processing without condition-case?

See Drew's answer to a related question. If you do not mind ignoring all errors (I do not know which errors read might signal), you should use ignore-errors. Otherwise, your error handler should ...
Basil's user avatar
  • 12.6k
5 votes
Accepted

Read input char without pressing RET

You apparently want to read a character and immediately dispatch behavior based on what it is. Help > Search Documentation > Find Any Object by Name (command apropos) tells you, for read plus char ...
Drew's user avatar
  • 79.1k
4 votes
Accepted

How to preselect initial text in the minibuffer with Elisp?

Use macro minibuffer-with-setup-hook to set the mark at the end of the minibuffer prompt. read-string then inserts the initial text with the mark active, which means that initial text is selected as ...
Drew's user avatar
  • 79.1k
4 votes
Accepted

Read a config file and get some value into elisp variable

Try this: (with-temp-buffer (insert-file-contents "config.dat") (keep-lines "contexts" (point-min) (point-max)) (setq ctx (when (string-match "contexts: \\(.*\\)" (buffer-string)) (...
John Kitchin's user avatar
  • 12.1k
4 votes

the Term “Hash Notation“ in the Elisp Manual

Just for the second question: The “Hash Notation” is just a kind of notation using “#”. The mark “#” is named “hash mark”, so there is nothing to do with “hash function”.
Segrece's user avatar
  • 83
3 votes
Accepted

When does Emacs enter command loop?

The sequence to entering the command loop for the first time is: main() /* defined in src/emacs.c */ Frecursive_edit() /* defined in src/keyboard.c */ recursive_edit_1() /* ...
phils's user avatar
  • 53k
3 votes
Accepted

How can I read a number as user input?

What function should I call read-number how should it be used You can call it directly, e.g., (read-number ""). But if you are writing a function, I recommend you put (interactive "n&...
shynur's user avatar
  • 5,890
3 votes

Read first N lines of file into list

You're still going need to read the entire file, but you don't have to process every line, since you need just first N lines. (defun your-read-lines (file n) "Return first N lines of FILE." (with-...
xuchunyang's user avatar
  • 14.8k
2 votes

How to read elisp file into s-expression?

Based on John Kitchin's solution, I come up with the following solution which inserts the needed text before and after the file contents: (with-temp-buffer (save-excursion (insert "(progn\n") ...
Alex Vong's user avatar
  • 171
2 votes
Accepted

read: Transferring an alist (containing a comma) from a file to a variable

You know from your recent Q&A why the comma is being handled that way. The fact is that read is for reading lisp syntax into lisp objects, and so you can only expect the results to be as they ...
phils's user avatar
  • 53k
2 votes
Accepted

Filter the content read from file

The answer to any "Is it possible" question is almost always yes (there is a theorem by Turing which tells us the limit of what is computable, but in practice people rarely come up against that limit)....
db48x's user avatar
  • 19.1k
2 votes

the Term “Hash Notation“ in the Elisp Manual

It seems that the GNU Emacs Lisp Reference Manual has actually cleared up this misunderstanding. See Chapter 8 Hash Tables: Hash notation, the initial ‘#’ character used in the printed ...
shynur's user avatar
  • 5,890
1 vote
Accepted

the Term “Hash Notation“ in the Elisp Manual

I’m not really sure that there is a widely–recognized name for these things in Emacs Lisp. The language has grown and changed over time, and things have been added to the language as needed. You could ...
db48x's user avatar
  • 19.1k
1 vote
Accepted

Make the minibuffer prompt always have a default argument

I am not sure if this will cause any problems when calling some other functions (it is pefectly save to try it), but as mentioned by Drew already, you could advise the 'underlying' functions. For goto-...
dalanicolai's user avatar
  • 7,985
1 vote

Make the minibuffer prompt always have a default argument

[I edited the tags and title: The question is not about the prompt; it's about providing a default value when reading from the minibuffer. That the default is generally shown in the prompt is ...
Drew's user avatar
  • 79.1k
1 vote

How to read multiple expressions from stream?

If you want to read all the expressions from the string "(+ 1 2) (+ 2 3)" just wrap it by an extra pair of parantheses to represent a list, i.e., read "((+ 1 2) (+ 2 3))" instead. ...
Tobias's user avatar
  • 33.7k
1 vote

How to read multiple expressions from stream?

I slightly modified the answer in How should you read a Lisp file as Lisp for processing without condition-case? to get (defun read-multiple (string) "Read STRING and return a list of its Lisp ...
B B's user avatar
  • 21
1 vote

How to read multiple expressions from stream?

"(+ 1 2) (+ 2 3)" is not a stream, it is a string. Strings do not keep track of what has been read already and what should be read next, so if you call read on this string multiple times you ...
db48x's user avatar
  • 19.1k
1 vote
Accepted

read-char-from-minibuffer for optional argument

(require 's) ; for s-blank-str-p ... (interactive (list (read-char-from-minibuffer "Opening Bracemark: ") (let ((x (read-char-from-minibuffer "Closing Bracemark: ")...
Phil Hudson's user avatar
  • 1,798
1 vote

How to read an s-expression at load-time

On startup, I get this output in the Messages buffer: BEG: 1 END: 1 For information about GNU Emacs and the GNU system, type C-h C-a. No matter where I place that s-expression (point) will always ...
phils's user avatar
  • 53k
1 vote
Accepted

Is there an easy way to use thing-at-point to initialize interactive read string (interactive "sfoo:")

Yes, use interactive with a Lisp sexp, not a literal string. You can't specify particular defaulting with a literal string arg. You can use read-from-minibuffer, read-string, or completing-read. ...
Drew's user avatar
  • 79.1k
1 vote
Accepted

How set default number (1) in the interactive custom function

Use read-number directly: (interactive (list (read-number "Input increment number: " 1)))
phils's user avatar
  • 53k
1 vote

How to evaluate Elisp code contained in a string?

In my case I wanted to evaluate elisp in a string only if it actually was valid elisp. Otherwise I just wanted the string as-is. (defun maybe-eval-string (string) "Maybe evaluate elisp in a ...
Chris's user avatar
  • 173

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