GNU bug report logs -
#62892
proposal to extend mark-sexp to go forward and backward on command
Previous Next
Full log
Message #83 received at 62892 <at> debbugs.gnu.org (full text, mbox):
[Message part 1 (text/plain, inline)]
Attached is a patch with the following changes:
* Uses the helper function to create mark-foo-forward, mark-foo-backward
for word, paragraph, sexp, page, and defun.
* Adds tests for all of these.
* Adds these new functions to etc/NEWS and various .texi files in
doc/emacs/.
On Thu, May 4, 2023 at 12:48 AM Zachary Kanfer <zkanfer <at> gmail.com> wrote:
> > Is it an "internal" function? Then its name should
> > maybe use `--'. (But why should it be internal?)
>
> Hrm, I figured it would be an internal function because it's intended to
> be wrapped by other code. But this describes a whole lot of functions. So
> it can't be that.
>
> I suppose that if there are other types of things that are created that
> one might want to mark, then a user could use this method to mark them. So
> perhaps it shouldn't be internal -- it really could be used by other code.
>
> > Is it a helper function? Then its name should maybe
> > use a suffix that indicates that, such as `-helper'
> > or `-1' (old-school Lisp, I suppose).
>
> It's certainly a helper function -- it's intended to be called by a bunch
> of different functions we write.
>
> > `mark-thing' should be reserved for a function that
> > takes a THING name as arg: `sexp', `page', etc.,
> > instead of a movement function such as `forward-sexp'.
>
> This makes a lot of sense to me.
>
> On Fri, Apr 28, 2023 at 3:28 PM Drew Adams <drew.adams <at> oracle.com> wrote:
>
>> > > +(defun mark--helper (move-fn number-of-things)
>> >
>> > A nicer name would be 'mark-thing' as a reference to thingatpt.el.
>>
>> FWIW, I have a different take on this.
>>
>> Is it an "internal" function? Then its name should
>> maybe use `--'. (But why should it be internal?)
>>
>> Is it a helper function? Then its name should maybe
>> use a suffix that indicates that, such as `-helper'
>> or `-1' (old-school Lisp, I suppose).
>>
>> `mark-thing' should be reserved for a function that
>> takes a THING name as arg: `sexp', `page', etc.,
>> instead of a movement function such as `forward-sexp'.
>> ___
>>
>> FWIW, I think MOVE-FN is a fine name for the argument.
>> My own preference, and what I use in my code, is the
>> name FORWARD-THING-FUNCTION.
>> ___
>>
>> FWIW, in my library isearch+.el), I use the arg name
>> THING for a thing name, not a movement or other
>> function.
>>
>> E.g.: Function `isearchp-in-thing-p' is a helper
>> function for defining specific THING-type predicates,
>> such as `isearch(-not)-in-email-address-p'.
>> ___
>>
>> FWIW, my library `thing-cmds.el' has a command named
>> `mark-things', which prompts for a THING type as arg:
>>
>> mark-things is an alias for 'select-things' in 'thing-cmds.el'.
>>
>> (mark-things THING &optional ARG ALLOW-EXTEND)
>>
>> Set point at one end of THING and set mark ARG THINGs from point.
>> THING is a symbol that names a type of thing. Interactively, you are
>> prompted for it. Completion is available (lax).
>>
>> (If THING doesn't have an associated `forward-'THING operation then
>> do nothing.)
>>
>> Put mark at the same place command `forward-'THING would move point
>> with the same prefix argument.
>>
>> Put point at the beginning of THING, unless the prefix argument (ARG)
>> is negative, in which case put it at the end of THING.
>>
>> If `select-things' is repeated or if the mark is active (in Transient
>> Mark mode), then it marks the next ARG THINGs, after the ones already
>> marked. In this case the type of THING used is whatever was used the
>> last time `select-things' was called - you are not prompted for it.
>>
>> This region extension reusing the last type of THING happens even if
>> the active region is empty. This means that you can, for instance,
>> just use `C-SPC' to activate an empty region and then use
>> `select-things' to select more THINGS of the last kind selected.
>>
>> If there is no THING at point, and `thgcmd-use-nearest-thing-flag' is
>> non-nil, then select a THING near point.
>>
>>
[Message part 2 (text/html, inline)]
[0001-Add-foo-mark-forward-foo-mark-backward-for-various-f.patch (text/x-patch, attachment)]
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.