|
From: | arthur miller |
Subject: | Sv: Suggestion: two new commands: beginning-of-list and end-of-list |
Date: | Mon, 9 Sep 2024 19:41:51 +0000 |
I meant beginning-of-list, not beginning-of-string, was a lapsus.
Från: arthur miller <arthur.miller@live.com>
Skickat: den 9 september 2024 21:41 Till: Eli Zaretskii <eliz@gnu.org> Kopia: emacs-devel@gnu.org <emacs-devel@gnu.org> Ämne: Sv: Suggestion: two new commands: beginning-of-list and end-of-list
>> but actually not the one that places the cursor at the beginning of a list.
>
>I think we do have it: C-M-u, backward-up-list. What's more, it works
>not only in Lisp. I use it all the time.
Yes you have. It works slightly differently when you are in a string, and it
places cursor before the opening parenthesis, not after.
>So I wonder why we need another function that does basically the same.
I think it makes sense to keep backward-up-list as it is, since it handles
literal strings as it does. But the behaviour is controlled via special vars
esape-strings and no-syntax-crossing. If we want similar command as
beginning-of-string, we have to wrap it and let-bind those variables to
change how it works.
I am not sure, what is a symmetric function to move cursor to the end of list?
But as said in the previous mail: this function is *already* in Emacs, so it is
already taking the memory in the process. It is just not used more than
once, and have *potential* to be used more. In other words, I suggest these
two functions as a convenience, not because it is impossible to do something
similar via some combination of other commands and variables.
By the way, why did all occasions of the word "_expression_" ended up surroneded
with underscores in the online archive?
Från: Eli Zaretskii <eliz@gnu.org>
Skickat: den 9 september 2024 21:11 Till: arthur miller <arthur.miller@live.com> Kopia: emacs-devel@gnu.org <emacs-devel@gnu.org> Ämne: Re: Suggestion: two new commands: beginning-of-list and end-of-list > From: arthur miller <arthur.miller@live.com>
> Date: Mon, 9 Sep 2024 18:32:33 +0000 > > In elisp-mode.el, there is a function, IMO somewhat unfortunately named > "elisp--beginning-of-sexp". What this function does is to place cursor at the > beginning of the innermost list, which we can perhaps call more conveniently, > "current list". > > The function does so always, and is relatively well written, minor the case when > the cursor is placed in a literal string or outside a symbolic _expression_, say > between two top-level forms. In those cases, it jumps into the first string > before the current string, which might be anywhere in the file prior to the > current string, or to the beginning of the file. > > I took me a liberty to rename this function and update the doc to a more > appropriate wording, and turn it into a command. I have also patched the > above mentioned cases when it is invoked in a literal string or outside of > an _expression_. > > As another consideration, I have moved this function into lisp.el (in > lisp/emacs-lisp/) in the sources. It does not look like it has nothing > particularly specific to EmacsLisp per se, seems like it should work on any > "parenthesis"-language. I have tested it successfully in both CommonLisp and > EmacsLisp files. > > I found only one user of elisp--beginning-of-sexp in the entire Emacs, and that > is the function directly above: elisp--fnsym-in-current-sexp. > > Emacs already has few functions for motion over lists and symbolic expressions, > but actually not the one that places the cursor at the beginning of a list. I think we do have it: C-M-u, backward-up-list. What's more, it works not only in Lisp. I use it all the time. So I wonder why we need another function that does basically the same. Thanks. |
[Prev in Thread] | Current Thread | [Next in Thread] |