[-- Attachment #1: Type: text/plain, Size: 118 bytes --] I added a customization option to insert number sequence that can start with any value by default. Patch attached. [-- Warning: decoded text below may be mangled, UTF-8 assumed --] [-- Attachment #2: Patch 1 --] [-- Type: text/x-patch, Size: 1811 bytes --] From 72bdf5eed1079e265dff8636f5d316b9c971cb2f Mon Sep 17 00:00:00 2001 From: Daniel Fleischer <danflscr@gmail.com> Date: Wed, 12 Jan 2022 21:19:32 +0200 Subject: [PATCH] cua-rectangle initial sequence number customization * lisp/emulation/cua-base.el: define `cua-rectangle-sequence-start' * lisp/emulation/cua-rect.el (cua-sequence-rectangle): using the customized variable. --- lisp/emulation/cua-base.el | 4 ++++ lisp/emulation/cua-rect.el | 3 ++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/lisp/emulation/cua-base.el b/lisp/emulation/cua-base.el index 162d1bb641..da2c4ce870 100644 --- a/lisp/emulation/cua-base.el +++ b/lisp/emulation/cua-base.el @@ -389,6 +389,10 @@ cua-auto-tabify-rectangles (const :tag "Disabled" nil) (other :tag "Enabled" t))) +(defcustom cua-rectangle-sequence-start 0 + "Initial number when inserting a numerical sequence." + :type 'integer) + (defvar cua-global-keymap) ; forward (defvar cua--region-keymap) ; forward (declare-function cua-clear-rectangle-mark "cua-rect" ()) diff --git a/lisp/emulation/cua-rect.el b/lisp/emulation/cua-rect.el index e399fd0fbf..c90872e34b 100644 --- a/lisp/emulation/cua-rect.el +++ b/lisp/emulation/cua-rect.el @@ -1177,7 +1177,8 @@ cua-sequence-rectangle (list (if current-prefix-arg (prefix-numeric-value current-prefix-arg) (string-to-number - (read-string (format-prompt "Start value" 0) nil nil "0"))) + (read-string (format-prompt "Start value" cua-rectangle-sequence-start) + nil nil (number-to-string cua-rectangle-sequence-start)))) (string-to-number (read-string (format-prompt "Increment" 1) nil nil "1")) (read-string (concat "Format: (" cua--rectangle-seq-format ") ")))) -- 2.34.1 [-- Attachment #3: Type: text/plain, Size: 22 bytes --] -- Daniel Fleischer
Daniel Fleischer <danflscr@gmail.com> writes: > I added a customization option to insert number sequence that can start > with any value by default. Patch attached. What's the use case for that? (cua-sequence-rectangle isn't a command I've used before.) -- (domestic pets only, the antidote for overdose, milk.) bloggy blog: http://lars.ingebrigtsen.no
Lars Ingebrigtsen <larsi@gnus.org> writes:
> What's the use case for that? (cua-sequence-rectangle isn't a command
> I've used before.)
I'm using CUA rectangle mode a lot, mainly for fixing indentation and to
insert sequence of numbers for converting texts into numbered lists in
orgmode. The default initial number is 0 and you can input 1.
But then you do it a bunch of times and wonder why is it not
customizable. For example there is a format variable for the sequence
"%d" and it has a history mechanism so if you change it, it's ready for
the next time in a given session.
I thought it's too complicated to have a history for the initial value
and just customizing it would be simpler. That's the purpose of the
patch.
--
Daniel Fleischer
Daniel Fleischer <danflscr@gmail.com> writes: > I'm using CUA rectangle mode a lot, mainly for fixing indentation and to > insert sequence of numbers for converting texts into numbered lists in > orgmode. The default initial number is 0 and you can input 1. Ah, right. A zero-based default is perhaps not the most useful for most people? > But then you do it a bunch of times and wonder why is it not > customizable. For example there is a format variable for the sequence > "%d" and it has a history mechanism so if you change it, it's ready for > the next time in a given session. > > I thought it's too complicated to have a history for the initial value > and just customizing it would be simpler. That's the purpose of the > patch. Right. But perhaps it'd be even more useful if it updated the value from what the user answered? If the user answered "1" once, then it sounds likely that that's what the user wants next time, too, isn't it? -- (domestic pets only, the antidote for overdose, milk.) bloggy blog: http://lars.ingebrigtsen.no
Lars Ingebrigtsen [2022-01-13 Thu 08:04] wrote: > Ah, right. A zero-based default is perhaps not the most useful for most > people? I won't claim anything about most people. I give them the choice. > If the user answered "1" once, then it sounds likely that that's what > the user wants next time, too, isn't it? Well, this type of persistence is what customizing is all about.
> From: Daniel Fleischer <danflscr@gmail.com>
> Date: Thu, 13 Jan 2022 08:32:09 +0200
>
> Lars Ingebrigtsen <larsi@gnus.org> writes:
>
> > What's the use case for that? (cua-sequence-rectangle isn't a command
> > I've used before.)
>
> I'm using CUA rectangle mode a lot, mainly for fixing indentation and to
> insert sequence of numbers for converting texts into numbered lists in
> orgmode. The default initial number is 0 and you can input 1.
>
> But then you do it a bunch of times and wonder why is it not
> customizable. For example there is a format variable for the sequence
> "%d" and it has a history mechanism so if you change it, it's ready for
> the next time in a given session.
Would it make sense to allow specifying the initial value via the
prefix arg?
Eli Zaretskii <eliz@gnu.org> writes:
> Would it make sense to allow specifying the initial value via the
> prefix arg?
It's already implemented, I didn't know about that.
Anyways, if someone, like me, always uses this function for creating
numbered lists, they would like to set the starting number as 1, always.
So there is a use-case.