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 (...
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)
(...
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 ...
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 ...
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 ...
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 ...
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 ...
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))
(...
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”.
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() /* ...
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&...
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-...
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")
...
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 ...
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)....
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 ...
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 ...
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-...
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 ...
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.
...
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 ...
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 ...
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: ")...
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 ...
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.
...
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)))
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 ...
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
read × 30minibuffer × 5
interactive × 4
list × 3
eval × 3
elisp × 2
files × 2
string × 2
characters × 2
print × 2
init-file × 1
region × 1
commands × 1
help × 1
documentation × 1
message × 1
load × 1
events × 1
emacs27 × 1
numbers × 1
filtering × 1
default × 1
parsing × 1
defstruct × 1
key-translation-map × 1