all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: arthur miller <arthur.miller@live.com>
To: Eli Zaretskii <eliz@gnu.org>
Cc: "emacs-devel@gnu.org" <emacs-devel@gnu.org>
Subject: Sv: Suggestion: two new commands: beginning-of-list and end-of-list
Date: Wed, 11 Sep 2024 05:39:00 +0000	[thread overview]
Message-ID: <AS8PR02MB10107788F14E24E084EC3274C969B2@AS8PR02MB10107.eurprd02.prod.outlook.com> (raw)
In-Reply-To: <86plpbtsq7.fsf@gnu.org>

[-- Attachment #1: Type: text/plain, Size: 5212 bytes --]

>> >> 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.
>> >
>> >Yes, but is that a problem?
>>
>> Everyone who would like to customize it has to write their own.
>
>Why would someone want to customize a command that does its job well?

What kind of question is that? You are asking why would someone want to
customize Emacs? :-)

Obviously people have written packages to do something similar. Small
conventience might matter to people. With backward-up-list you have to
press at least one more time, or if you are in a doc string you have to
invoke it again.

>> Down-list? I don't think it is close to the end-of-list.
>
>Try it on a deeply-nested list, and you will see the difference.

Down list vill move you to the beginning of next list, not the end of a
list, it is a drastic difference, not comparable by any means:

(defun end-of-list ()
  "Move cursor to the beginning of current list.

Return the number of nested expressions the point was over or after."
  (interactive)
  (let ((parse-sexp-ignore-comments t)
      (num-skipped-sexps 0)
        (syntax (syntax-ppss)))| <- cursor before
    (unless (= 0 (nth 0 syntax)) ;; not in a list
      (when (nth 3 syntax) ;; in string
        (goto-char (nth 8 syntax)))
      (ignore-errors
        (progn
          ;; First account for the case the point is directly over a
          ;; beginning of a nested sexp.
          (ignore-errors
              (let ((p (point)))
              (forward-sexp 1)
              (forward-sexp -1)
              (when (> (point) p)
                (setq num-skipped-sexps 1))))
          (while
              (let ((p (point)))
              (forward-sexp 1)
              (when (> (point) p)
                (setq num-skipped-sexps (1+ num-skipped-sexps))))))))
    num-skipped-sexps))

Down-list puts cursor after the next open parenthesis: (|unless (= 0 ...
End-of-list puts cursor before the closing parenthesis of the let:

                   ( ... )
                (setq num-skipped-sexps (1+ num-skipped-sexps))))))))
    num-skipped-sexps|)) <-- cursor after the end-of-list

However, as Karthink pointed out up-list places cursor to the closing let
parenthesis so it is close, similar to backward-up-list, one C-b press
away from the end of a list, and it also handles the literal strings the
same way as backward-up-list (puts cursor after the closing string
quote). Btw, I wasn't using myself up-list, I was manipulating my cursor
by other means :).

Anyway, I still think it is an improvement to rename at least
elisp--beginning-of-sexp, to beginning-of-list.

Personally I also think beginning-of-list and end-of-list are slightly
more convenient and the connection between the name and what they do is
much more clear than backward-up-list and up-list. It might be just me,
I admit that one, at least I wasn't using those myself even though I
knew about them by the name. Obviously people who are using smartparens
are thinking similar (paredit does not have this either). Do a web
search and you will see questions on SX asking "how do I move cursor to
the end of list", and you will see Drew teaching them "you wish to move
out of list, up-list does that".

I don't understand why this response if I wish to add a small
convenience for users (and myself admittedly). There are so many other
small wrappers included in Emacs that does much less.
________________________________
Från: Eli Zaretskii <eliz@gnu.org>
Skickat: den 10 september 2024 17:48
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>
> CC: "emacs-devel@gnu.org" <emacs-devel@gnu.org>
> Date: Tue, 10 Sep 2024 15:10:26 +0000
>
> >> 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.
> >
> >Yes, but is that a problem?
>
> Everyone who would like to customize it has to write their own.

Why would someone want to customize a command that does its job well?

> >The converse of C-M-u is C-M-d, but it doesn't move to the end of a
> >list, it moves _inside_ one level.
>
> Down-list? I don't think it is close to the end-of-list.

Try it on a deeply-nested list, and you will see the difference.

[-- Attachment #2: Type: text/html, Size: 15440 bytes --]

  reply	other threads:[~2024-09-11  5:39 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-09-09 18:32 Suggestion: two new commands: beginning-of-list and end-of-list arthur miller
2024-09-09 19:11 ` Eli Zaretskii
2024-09-09 19:41   ` Sv: " arthur miller
2024-09-09 19:41     ` arthur miller
2024-09-10 11:30     ` Eli Zaretskii
2024-09-10 15:10       ` Sv: " arthur miller
2024-09-10 15:48         ` Eli Zaretskii
2024-09-11  5:39           ` arthur miller [this message]
2024-09-12  4:24             ` Emanuel Berg
2024-09-11  3:17     ` Sv: " Karthik Chikmagalur
2024-09-11  5:48       ` Sv: " arthur miller
2024-09-10 12:05 ` Yuri Khan

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=AS8PR02MB10107788F14E24E084EC3274C969B2@AS8PR02MB10107.eurprd02.prod.outlook.com \
    --to=arthur.miller@live.com \
    --cc=eliz@gnu.org \
    --cc=emacs-devel@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.