Questions tagged [sexp]
Originated from the Lisp “s-expression” (for an expression in Lisp), `sexp` in Emacs refers to an expression in any language your program is written in.
34
questions
8
votes
4
answers
1k
views
How can I find surrounding parenthesis (from emacs lisp)?
Is there a way to find out the type of the surrounding parenthesis (i.e. '(', '[' or '{') around point? For example (using | to represent point)
{ abc, | df }
should return '{', and
{ abc[ | ], ...
8
votes
4
answers
633
views
Correct pronunciation of 'sexp'?
I apologize if this is a dumb question, but I'm just starting out in ELisp, and I'm wondering how you pronounce the word 'sexp'.
I.e., if I was talking to someone, how does one say this word?
7
votes
2
answers
643
views
How can I view the full `package-alist` value (without the truncation characters "...")?
When I do C-h v package-alist, I see something like
((PACKAGE-NAME1 [cl-struct-package-desc
PACKAGE-NAME1
(VERSION1)
"DESCRIPTION1"
(...
7
votes
1
answer
438
views
fill-paragraph (`M-q`) for s-expressions?
With M-q (aka fill-paragraph), it is possible to format a single line of text nicely.
Is there a command or function which does a similar thing for lisps s-expressions?
It should break one-liner ...
5
votes
1
answer
694
views
how to properly move forward to the next sexp
I was expecting a similar result with the two snippets below, but this is what I've got:
(with-temp-buffer
(insert "(a)(b)(c)")
(goto-char (point-min))
(list
(prog1 (cons (point) (cons (sexp-...
5
votes
1
answer
191
views
How do I ignore comments with scan-sexps?
I have some lisp code that contains a comment:
(while list
;; take the head of LIST
(setq len 1))
I want to extract the positions of the sexps. I'm using scan-sexps. If I call M-: (scan-sexps 12 ...
4
votes
1
answer
412
views
Folding code between a literal "begin"/"end" block using Hideshow
A formatted input file (*.alm) often contains a large section of columned data. To fold this and improve navigation, I've tried to implement a hs-special-mode-alist entry from hideshow.el.
(setq hs-...
3
votes
1
answer
1k
views
Pretty print s expressions from the command line
I've got a file containing an emacs s-expression and I want to pretty print it from the command line: Is there an easy way of doing this? Paranoia suggests I want to do as little parsing of this data ...
3
votes
1
answer
134
views
forward-comment doesn't move the point
I tried running (forward-comment -1) by eval command, when the point is actually in the middle of a comment. Like forward-word (or) forward-line, i expected it move to the beginning of the comment &...
3
votes
1
answer
167
views
How can I make `forward-sexp` handle other balanced character-pairs such as < and > or << and >>?
I am trying to find an easy and efficient way to modify the behaviour of forward-sexp to handle balanced pairs of characters not normally supported by it, such as balanced < and > and balanced &...
3
votes
0
answers
746
views
How to go to the beginning of a word/sexp?
When the point is not at the beginning of a word/sexp, backward-word / backward-sexp places the cursor at the beginning of that word/sexp. If the point is already at the beginning of a word/sexp, this ...
3
votes
1
answer
76
views
How can I find corresponding balanced parentheses?
I have this LaTeX code:
\caption{Lorem ipsum dolor sit amet: foo), bar), baz) and qux) consectetuer adipiscing elit.}
I want to put a marker immediately before the first { and one immediately after ...
2
votes
4
answers
873
views
A elisp function to jump between matched pair
Here is the function spec: (defun jump-to-matched (open-char closed-char) )
say the content of current buffer is "a([b]c()d)".
If I move the cursor over the first "(" and run (jump-to-matched "(" ")...
2
votes
1
answer
273
views
Navigating lisp
I want to programmatically navigate emacs lisp (and similar "nested paren code").
Specific functions I want:
Go to first child (which errors if there are no children (maybe lispy-outline-goto-child ...
2
votes
0
answers
17
views
Make a set of characters act as open/close syntax?
Is there a way to make a set of characters act syntactically as open/close brackets? For example, {a> as an opening bracket, and <a} as a closing bracket? I know how to do this with single ...
2
votes
0
answers
121
views
Marking sexp diary entries as done in org agenda
I often use sexp diary entries for events in ORG-AGENDA. Is there a way of marking them as "DONE" in agenda-view?
E.g. %%(diary-float t 2 3) Send John info for Bulletin
E.g. %%(diary-block 12 15 ...
2
votes
0
answers
477
views
Orgmode : exporting agenda with sexps to ics
This year, I am having classes with complex descriptions, such as "every 1st and 3rd friday between 2016-11-18 and 2017-5-19", so I chose to use org-mode agenda combined with sexps to describe them ...
1
vote
1
answer
40
views
Highlight car of each sexpr in source
All the syntax highlighting suggestions I've managed to find so far are keyword driven. I'm reading data written in s-expressions that doesn't have keywords, but the car of each list is still somewhat ...
1
vote
1
answer
67
views
Parse-Partial-Sexp State at POS
What is Parse-Partial-Sexp State at POS? Because I have been looking at some elisp code calling syntax-ppss.
I have the variable ppss being set to either (syntax-ppss) or to (parse-partial-sexp last-...
1
vote
1
answer
275
views
Forward, backward etc sexp not working
I want to use the forward-sexp function in Emacs, which on my Spacemacs for Mac is bound to C-M-f.
Similarly for the backward-sexp. However, upon pressing C- for Control, and then the Meta key, which ...
1
vote
1
answer
107
views
How does `eval-last-sexp` determine the expression for evaluation?
Context: Emacs 29.0.60
The ▬ and the empty lines after the script text below are point positions at which the interactively executed function eval-last-sexp echoes in the minibuffer and the *Messages* ...
1
vote
1
answer
410
views
How can I skip 'Scan-error: "Unbalanced parentheses"...'?
I want to write a script in order to correct spaces inside section command in a LaTeX code, that's to say
\section{Lorem ipsum dolor
sit amet consectetuer adipiscing
elit}
should be
\section{...
1
vote
2
answers
313
views
How can I bring tex-mode's sexp navigation to AucTeX?
I generally prefer AucTeX over the built-in tex-mode, but one thing that is much better in tex-mode is navigation by s-expression. Namely, in tex-mode, forward-sexp (C-M-f) treats LaTeX environments ...
1
vote
0
answers
59
views
Different summaries at different levels in org-columns
I'm trying to use org-mode for keeping track of my grades in university. My grades are all numerical from 0 to 10. I want the column view to output my average score and the final grade of each subject,...
1
vote
0
answers
137
views
Sending an s-expression to another buffer
I'm currently working in Clojure with Arcadia, which is requiring me to use a REPL that doesn't have support with Cider. This has been giving me some trouble given how I usually code, so I'd like to ...
0
votes
1
answer
73
views
Org export "invalid function" error
This is my export.el:
(require 'ox-publish)
(setq org-publish-project-alist
'(
("org-notes"
:base-directory "~/org/"
:base-extension "org"
:publishing-directory ...
0
votes
1
answer
56
views
Why having a system loaded makes any difference for indentation?
I am using Common Lisp, SBCL, Emacs, and Slime. During a code review, a co-worker mentioned that the indentation of an s-expression was wrong.
Usually, I just use indent-sexp(bounded to C-M-q) to fix ...
0
votes
1
answer
325
views
forward-sexp confusion
The following code is an excerpt from the elisp tutorial, section 14.6.
(while (re-search-forward "^(defun" nil t)
(setq lengths-list (cons (count-words-in-defun) lengths-list)))
Placing the ...
0
votes
1
answer
163
views
Unclear expectation of behavior from `scan-sexps`
The docstring of scan-sexps says:
If the beginning or end is reached between groupings but before count is used up, nil is returned.
Putting point (|) before the first element of a list:
(|a b c)
...
0
votes
1
answer
54
views
moving cursor forward-sexp goes one char further in evil mode
When I want to highlight the following region
(a ( b ( c ) ) ) )
I get
(a ( b ( c ) ) ) )
I mark the beginning and do forward-sexp (or sp-forward-sexp, which results in the same outcome)
In, insert ...
0
votes
0
answers
32
views
Make sexp-at-point ignore ";" in LaTeX mode
I have this LaTeX code:
$K(U_1, V_1, x_1; t_2, x_2)$
I found that the string/expression (U_1, V_1, x_1; t_2, x_2) is not recognized as an s-expression by the command (sexp-at-point) (in latex-mode) ...
0
votes
0
answers
26
views
How to delete a function on which a cursor is in Spacemacs?
Let's say I have this:
(defn -main [& args]
(my-func|tion 5) (my-function-2 "hello")
(third-function-of-mine nil))
where | is my cursor.
And I want to delete (my-function 5).
So in ...
0
votes
0
answers
65
views
filtering `sexp` entries in org-agenda
I have an org entry with a sexp and a tag:
* test :test_tag:
%%(org-anniversary 2000 08 23) test anniversary
When I open my agenda "test anniversary" shows up as it should (I'm writing ...
-1
votes
1
answer
156
views
mark-sexp (Wrong number of arguments)
((foo(bar)) ...