GNU bug report logs - #62892
proposal to extend mark-sexp to go forward and backward on command

Previous Next

Package: emacs;

Reported by: Zachary Kanfer <zkanfer <at> gmail.com>

Date: Mon, 17 Apr 2023 02:26:02 UTC

Severity: normal

Full log


Message #65 received at 62892 <at> debbugs.gnu.org (full text, mbox):

From: Juri Linkov <juri <at> linkov.net>
To: Zachary Kanfer <zkanfer <at> gmail.com>
Cc: Ruijie Yu <ruijie <at> netyu.xyz>, Stefan Monnier <monnier <at> iro.umontreal.ca>,
 62892 <at> debbugs.gnu.org
Subject: Re: bug#62892: proposal to extend mark-sexp to go forward and
 backward on command
Date: Fri, 28 Apr 2023 20:04:48 +0300
> Attached is a patch with a few updates:

Thanks for the patch.  It would be nice to have such commands
even not bound to default keys, so the users are free to bind
them to any keys.

> I'm not exactly sure of the best place to put the helper function, nor
> exactly how the different lisp files in Emacs work together. There's no
> provide statement; are all the files in lisp/emacs-lisp loaded at the same
> time? If so, I'll make the other relevant functions (for marking word,
> defun, page, paragraph, line, and char).

Let's see:
- mark-sexp and mark-defun are defined in emacs-lisp/lisp.el
- mark-page in textmodes/page.el
- mark-paragraph in textmodes/paragraphs.el
- mark-word in simple.el

So looks like the best place to define the helper is simple.el,
before mark-word.

> +(defun mark--helper (move-fn number-of-things)

A nicer name would be 'mark-thing' as a reference to thingatpt.el.

> +  "Use MOVE-FN to move NUMBER-OF-THINGS things, extending region over them.
> +
> +The MOVE-FN should take a numeric argument, and move that many
> +items forward (negative means backward).
> +
> +NUMBER-OF-THINGS is the number of additional things to move."

Another variant is to use a single argument JUMPFORM like
in 'isearch-yank-internal' that allows not to leak the
prefix argument to the helper function:

  (defun isearch-yank-char (&optional arg)
    (isearch-yank-internal (lambda () (forward-char arg) (point))))




This bug report was last modified 2 years and 17 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.