unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* [PATCH] customizing initial sequence number in cua-rectangle
@ 2022-01-12 19:28 Daniel Fleischer
  2022-01-13  6:00 ` Lars Ingebrigtsen
  0 siblings, 1 reply; 7+ messages in thread
From: Daniel Fleischer @ 2022-01-12 19:28 UTC (permalink / raw)
  To: emacs-devel

[-- 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

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] customizing initial sequence number in cua-rectangle
  2022-01-12 19:28 [PATCH] customizing initial sequence number in cua-rectangle Daniel Fleischer
@ 2022-01-13  6:00 ` Lars Ingebrigtsen
  2022-01-13  6:32   ` Daniel Fleischer
  0 siblings, 1 reply; 7+ messages in thread
From: Lars Ingebrigtsen @ 2022-01-13  6:00 UTC (permalink / raw)
  To: Daniel Fleischer; +Cc: emacs-devel

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



^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] customizing initial sequence number in cua-rectangle
  2022-01-13  6:00 ` Lars Ingebrigtsen
@ 2022-01-13  6:32   ` Daniel Fleischer
  2022-01-13  7:04     ` Lars Ingebrigtsen
  2022-01-13  8:56     ` Eli Zaretskii
  0 siblings, 2 replies; 7+ messages in thread
From: Daniel Fleischer @ 2022-01-13  6:32 UTC (permalink / raw)
  To: emacs-devel

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




^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] customizing initial sequence number in cua-rectangle
  2022-01-13  6:32   ` Daniel Fleischer
@ 2022-01-13  7:04     ` Lars Ingebrigtsen
  2022-01-13  7:17       ` Daniel Fleischer
  2022-01-13  8:56     ` Eli Zaretskii
  1 sibling, 1 reply; 7+ messages in thread
From: Lars Ingebrigtsen @ 2022-01-13  7:04 UTC (permalink / raw)
  To: Daniel Fleischer; +Cc: emacs-devel

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



^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] customizing initial sequence number in cua-rectangle
  2022-01-13  7:04     ` Lars Ingebrigtsen
@ 2022-01-13  7:17       ` Daniel Fleischer
  0 siblings, 0 replies; 7+ messages in thread
From: Daniel Fleischer @ 2022-01-13  7:17 UTC (permalink / raw)
  To: emacs-devel

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. 




^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] customizing initial sequence number in cua-rectangle
  2022-01-13  6:32   ` Daniel Fleischer
  2022-01-13  7:04     ` Lars Ingebrigtsen
@ 2022-01-13  8:56     ` Eli Zaretskii
  2022-01-13 10:15       ` Daniel Fleischer
  1 sibling, 1 reply; 7+ messages in thread
From: Eli Zaretskii @ 2022-01-13  8:56 UTC (permalink / raw)
  To: Daniel Fleischer; +Cc: emacs-devel

> 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?



^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] customizing initial sequence number in cua-rectangle
  2022-01-13  8:56     ` Eli Zaretskii
@ 2022-01-13 10:15       ` Daniel Fleischer
  0 siblings, 0 replies; 7+ messages in thread
From: Daniel Fleischer @ 2022-01-13 10:15 UTC (permalink / raw)
  To: emacs-devel

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.





^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2022-01-13 10:15 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-01-12 19:28 [PATCH] customizing initial sequence number in cua-rectangle Daniel Fleischer
2022-01-13  6:00 ` Lars Ingebrigtsen
2022-01-13  6:32   ` Daniel Fleischer
2022-01-13  7:04     ` Lars Ingebrigtsen
2022-01-13  7:17       ` Daniel Fleischer
2022-01-13  8:56     ` Eli Zaretskii
2022-01-13 10:15       ` Daniel Fleischer

Code repositories for project(s) associated with this inbox:

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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).