Questions tagged [read]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
2 votes
1 answer
59 views

When does Emacs enter command loop?

I'm reading (info "(elisp) Command Overview"): Variable: post-command-hook : ... ... : This hook is also run when Emacs first enters the command loop (at which point this-command and last-...
shynur's user avatar
  • 4,272
0 votes
1 answer
28 views

How can I read a number as user input?

I would like a user to input a number using the minibuffer. What function should I call and how should it be used?
Dilna's user avatar
  • 1,183
2 votes
0 answers
37 views

Inconsistency between read-key and read-key-sequence-vector w.r.t. conditional application of local-function-key-map translations

While working with read-key-sequence-vector and read-key, I found that the former applies the local-function-key-map translations in a conditional manner but the latter does not. I am using Emacs 28.1 ...
Susam Pal's user avatar
  • 186
0 votes
1 answer
25 views

How to read-from-string, but keep strings inside as it is?

With a elisp piece of code: (message "%s" (read-from-string "(setq a \"a string here\" )")) I got result: ((setq a a string here) . 25) But I want result is: ((setq a &...
ri wen's user avatar
  • 3
4 votes
3 answers
173 views

the Term “Hash Notation“ in the Elisp Manual

I'm reading GNU Emacs Lisp Reference Manual, and I see the phrase "hash notation". Two places in the document seem to have different interpretations, so I have 2 questions. 2.1 Printed ...
shynur's user avatar
  • 4,272
1 vote
2 answers
128 views

Make the minibuffer prompt always have a default argument

Is it possible to make the first history item available as the default argument when running commands like eval-expression and goto-line? I'd like to be able to just press enter to use the previous ...
Matt's user avatar
  • 15
0 votes
1 answer
74 views

Setting completion-styles with read-multiple-choice

Am playing with read-multiple-choice to set completion-styles. Originally had (nth 1 sentry) but with '(basic substring), it will only pick up substring. Thus I can instead call (setq completion-...
Dilna's user avatar
  • 1,183
1 vote
1 answer
48 views

How to preselect initial text in the minibuffer with Elisp?

I'm using read-string to read a string from the minibuffer, with an initial input. How can I highlight the initial input, so that I can start replacing it with one key stroke? IOW, given (read-string &...
Arch Stanton's user avatar
  • 1,555
1 vote
3 answers
54 views

How to read multiple expressions from stream?

When calling (read "(+ 1 2) (+ 2 3)"), I get (+ 1 2), as expected. How can I get the next expression, namely (+ 2 3)?
Josh Cho's user avatar
0 votes
1 answer
46 views

read-char-from-minibuffer for optional argument

The following counts the number of opening (brcmk-beg) and closing (brcmk-end) braces. Having brcmk-end an optional argument, I would like to print $begmk nil $count-begmk 0 when the user either ...
Dilna's user avatar
  • 1,183
0 votes
1 answer
58 views

Reading a word or regular expression from the mini-buffer to a function

What function should I call to read a word or regular expression from the minibuffer? Am writing a function that accepts a word or regular expression and counts the number of matches. But need to ...
Dilna's user avatar
  • 1,183
0 votes
1 answer
40 views

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

I have a file, "/path/to/token-file.el", which contains an alist: ((access ((access_token 123abc456) (timestamp ((43 5 21 29 12 2021 3 nil 0) (Wed, 29 Dec 2021 21:05:43 GMT)...
lawlist's user avatar
  • 18.9k
2 votes
0 answers
28 views

Distinguish expected from erroneous end-of-file in read function?

What is the correct way to use (read (current-buffer)) to read from a buffer until the end of the file is reached? When no forms remain in a buffer, Emacs signals an error: (with-temp-buffer ...
kdb's user avatar
  • 1,561
0 votes
1 answer
58 views

How to read an s-expression at load-time

Why does it seem impossible to read an s-expression at load-time? Given this and only this s-expression in my init file: (save-excursion (end-of-defun) (beginning-of-defun) (setq beg (point)) (...
John DeBord's user avatar
6 votes
1 answer
1k views

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

I would like to convert these two strings "(a b c)" "(9 . 3)" to these (a b c) (9 . 3) I'd had some luck with the first one evaluating this, (mapcar 'intern (split-string (string-...
C11g's user avatar
  • 333
1 vote
1 answer
114 views

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

Is there an easy way to use thing-at-point to initialize the contents of an interactive string reading? I have a function the looks something like this: (defun foo (string) (interactive "...
intel_chris's user avatar
1 vote
1 answer
211 views

Filter the content read from file

(This follows the answer to the question: Completion of sentences stored in a file.) Suppose I have a file, the content of which being organized thanks to org-mode: * Dreams ≠ reality Please, don'...
Denis Bitouzé's user avatar
4 votes
1 answer
1k views

Read first N lines of file into list

The general way this seems to be done using Elisp is to first read the entire file using something like insert-file-contents-literally or find-file-no-select, using split-string on a newline, and then ...
Lorem Ipsum's user avatar
  • 4,347
0 votes
1 answer
144 views

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

here custom function: (defun increment-number-at-point(number) (interactive "nInput increment number:") (skip-chars-backward "0-9") (or (looking-at "[0-9]+") (error "No number at point")) ...
a_subscriber's user avatar
  • 3,884
2 votes
1 answer
474 views

What does hash s indicate in lisp

This is the result of M-: (elfeed-search-selected :ignore-region) #s(elfeed-entry ("www.cbc.com.com" . "https://www.cbc.com.com/defg/Polyglot-programming_%7E017e364530a5359046?source=rss") ...
american-ninja-warrior's user avatar
1 vote
0 answers
48 views

What methods are available for complex user input?

I am experimenting with writing a plugin which requires quite a bit of user input, its a front end to an api. A typical request will have 4 required inputs and many optional inputs, obviously I can ...
Oly's user avatar
  • 583
4 votes
2 answers
2k views

How to read elisp file into s-expression?

I have a file of elisp code, say foo.el. I want to turn the content into a s-expression, so that I can play with it. Right now, I use the following method: Read foo.el into a string. Turn the string ...
Alex Vong's user avatar
  • 161
2 votes
1 answer
300 views

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

To help catch predictable errors, I've written my own linting tasks that read the code and report any inconsistencies it finds. One of the hackier pieces to this right now is the following function: ...
Sean Allred's user avatar
  • 6,851
1 vote
1 answer
566 views

Read input char without pressing RET

I want to perform the same task as in the function below, but without having to press ENTER every time I select an option. (defun my-fun () (interactive) (setq something (read-string "Options:\n [...
Jacek's user avatar
  • 35
1 vote
0 answers
70 views

How do I read and parse other Lisps in Emacs

I am playing with LFE language and I try to improve documentation lookup. Some of my efforts can be seen on my Github repo I have a function sexp-at-point which return a string enclosed by round ...
ruby_object's user avatar
12 votes
1 answer
1k views

Meaning of period in (. 123)

I learnt . /path/to/file in bash is used to execute a file. Just out of curiosity, I eval something like the following in Emacs (. 123) ⇒ 123 (read "(. 123)") ⇒ 123 It looks like Emacs ...
xuchunyang's user avatar
  • 14.3k
2 votes
1 answer
1k views

Read a config file and get some value into elisp variable

I'm trying to read a value of variable context from the config file. I use something like this (but have got an error..): (with-current-buffer (insert-file-contents "/home/user/liquibase.properties") ...
egor7's user avatar
  • 123
3 votes
1 answer
1k views

How to handle end of file during parsing errors while reading a string?

I was trying to read and eval Lisp forms from a string using a loop, instead of just putting the string into a buffer and using eval-buffer to load everything in the string. That method was mentioned ...
Kevin's user avatar
  • 1,308
25 votes
3 answers
4k views

How to evaluate Elisp code contained in a string?

The question pretty much says it all: I have a string containing the source code for a valid Elisp expression, and I would like to evaluate it. (In Python, for example, the expression eval("1 - 2 + 3"...
kjo's user avatar
  • 3,155
2 votes
1 answer
93 views

How to add-to-list to read-in file contents

When I do this (setq v (f-read-text "s.el")) where s.el is of this form ((thing1 . thing2) (thing3 . thing4)) I get v back as one long string. And (setq v (append (f-read-text "s.el"))) doesn't seem ...
147pm's user avatar
  • 2,917