* bug#4382: [PATCH] lisp/rect.el: (rectangle-number-lines): New user key binding C-x r N
@ 2009-09-09 10:04 Jari Aalto
2009-09-10 14:59 ` Richard Stallman
` (2 more replies)
0 siblings, 3 replies; 7+ messages in thread
From: Jari Aalto @ 2009-09-09 10:04 UTC (permalink / raw)
To: submit; +Cc: Scott Evans
[-- Attachment #1: Type: text/plain, Size: 781 bytes --]
Scott has just informaed me that his FSF assignment papers have been
processed and cleared. Based on his work at
http://www.antisleep.com/elisp/gse-number-rect.el I propose following
new feature to be added to the rect.el package.
2009-03-22 Jari Aalto <jari.aalto@cante.net>
* rect.el (rectangle-number-lines): New user function.
(rectangle-number-line-callback): New function.
(rectangle-number-line-format-history): New variable.
(rectangle-number-line-counter): New variable.
(define-key ctl-x-r-map "N" 'number-rectangle): New
user key binding. The basis of the rectangle numbering code was
lifted from gse-number-rect.el, orignally developed by Scott Evans
<gse@antisleep.com>. Used by permission (GPL).
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-lisp-rect.el-rectangle-number-lines-New-user-key-bin.patch --]
[-- Type: text/x-diff, Size: 2631 bytes --]
From 3ea550b85ded33fae27305bca8710e8f7ce0893b Mon Sep 17 00:00:00 2001
From: Jari Aalto <jari.aalto@cante.net>
Date: Sun, 22 Mar 2009 17:27:42 +0200
Subject: [PATCH] lisp/rect.el: (rectangle-number-lines): New user key binding C-x r N
Signed-off-by: Jari Aalto <jari.aalto@cante.net>
---
lisp/rect.el | 40 ++++++++++++++++++++++++++++++++++++++++
1 files changed, 40 insertions(+), 0 deletions(-)
diff --git a/lisp/rect.el b/lisp/rect.el
index eb188fc..6b63c81 100644
--- a/lisp/rect.el
+++ b/lisp/rect.el
@@ -39,6 +39,7 @@
;;;###autoload (define-key ctl-x-r-map "y" 'yank-rectangle)
;;;###autoload (define-key ctl-x-r-map "o" 'open-rectangle)
;;;###autoload (define-key ctl-x-r-map "t" 'string-rectangle)
+;;;###autoload (define-key ctl-x-r-map "N" 'number-rectangle)
;;; Code:
@@ -395,6 +396,45 @@ rectangle which were empty."
(delete-region pt (point))
(indent-to endcol)))))
+(defvar rectangle-number-line-counter nil
+ "Variable holding line numbering information.
+Initial value is set in function `rectangle-number-lines'
+and incremented for each line in `rectangle-number-line-callback'.")
+
+(defvar rectangle-number-line-format-history nil
+ "History variable that records previous format strings.")
+
+(defun rectangle-number-line-callback (start end format-string)
+ (move-to-column start t)
+ (setq rectangle-number-line-counter (+ rectangle-number-line-counter 1))
+ (insert (format format-string rectangle-number-line-counter)))
+
+(defun rectangle-number-lines (beg end start-at format &optional no-zero-padding)
+ "Insert numbers in front of lines in rectangle BEG END.
+
+START-AT specifices the first number to start at.
+FORMAT is format string where %i denotes inserted number.
+
+If prefix arg NO-ZERO-PADDING is non-nil, do not padd numbers
+with leading zeroes."
+ (interactive
+ (list
+ (region-beginning)
+ (region-end)
+ (if (functionp 'read-number)
+ (read-number "First number [1]: " 1)
+ (string-to-int (read-string "First number [1]: " nil nil "1")))
+ (read-string "Format: " "%i " 'rectangle-number-line-format-history)
+ current-prefix-arg))
+ (setq start-at (- start-at 1))
+ (unless no-zero-padding
+ (let* ((max (+ (count-lines beg end) start-at))
+ (longest (length (int-to-string (+ 1 max))))
+ (fmt (concat "%0" (int-to-string longest) "i")))
+ (setq format (replace-regexp-in-string "%i" fmt format))))
+ (setq rectangle-number-line-counter start-at)
+ (apply-on-rectangle 'rectangle-number-line-callback beg end format))
+
(provide 'rect)
;; arch-tag: 178847b3-1f50-4b03-83de-a6e911cc1d16
--
1.6.3.3
^ permalink raw reply related [flat|nested] 7+ messages in thread
* bug#4382: [PATCH] lisp/rect.el: (rectangle-number-lines): New user key binding C-x r N
2009-09-09 10:04 bug#4382: [PATCH] lisp/rect.el: (rectangle-number-lines): New user key binding C-x r N Jari Aalto
@ 2009-09-10 14:59 ` Richard Stallman
2009-09-10 16:59 ` Jari Aalto
[not found] ` <handler.4382.B.125249070423585.ack@emacsbugs.donarmstrong.com>
2009-09-16 10:52 ` bug#4382: [PATCH] lisp/rect.el: (rectangle-number-lines): New user key binding C-x r N Dan Nicolaescu
2 siblings, 1 reply; 7+ messages in thread
From: Richard Stallman @ 2009-09-10 14:59 UTC (permalink / raw)
To: Jari Aalto, 4382; +Cc: submit, gse
What does this feature do?
Where is the text to describe it?
^ permalink raw reply [flat|nested] 7+ messages in thread
* bug#4382: [PATCH] lisp/rect.el: (rectangle-number-lines): New user key binding C-x r N
2009-09-10 14:59 ` Richard Stallman
@ 2009-09-10 16:59 ` Jari Aalto
2009-09-11 21:00 ` Richard Stallman
0 siblings, 1 reply; 7+ messages in thread
From: Jari Aalto @ 2009-09-10 16:59 UTC (permalink / raw)
To: rms; +Cc: 4382, gse
[-- Attachment #1: Type: text/plain, Size: 1569 bytes --]
Richard Stallman <rms@gnu.org> writes:
> What does this feature do?
> Where is the text to describe it?
The code implements:
(define-key ctl-x-r-map "N" 'number-rectangle)
Where C-h f number-rectangle is described as:
Insert numbers in front of lines in rectangle BEG END.
START-AT specifices the first number to start at.
FORMAT is format string where %i denotes inserted number.
If prefix arg NO-ZERO-PADDING is non-nil, do not padd numbers
Demonstration, initial data:
Item one
Item two
Item three
Put cursor at first line's character, draw region up till last line's
first character. Call M-x number-rectangle:
First number [1] (default 1): <RET>
Format: %i <RET>
Result:
1 Item one
2 Item two
3 Item three
It the region would have been longer, say over 10 lines, the padding
would have taken in effect:
01 Item one
02 Item two
...
Jari
Here is slightly updated patch which corrects the name of the function
to `number-rectangle'.
2009-03-22 Jari Aalto <jari.aalto@cante.net>
* rect.el (number-rectangle): New user function.
(rectangle-number-line-callback): New function.
(rectangle-number-line-format-history): New variable.
(rectangle-number-line-counter): New variable.
(define-key ctl-x-r-map "N" 'number-rectangle): New
user key binding. The basis of the rectangle numbering code was
lifted from gse-number-rect.el, orignally developed by Scott Evans
<gse@antisleep.com>. Used by permission (GPL).
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-lisp-rect.el-number-rectangle-New-user-key-binding-C.patch --]
[-- Type: text/x-diff, Size: 2625 bytes --]
From cdf6167d8c8975f74a42d943f48b6db99fe9c678 Mon Sep 17 00:00:00 2001
From: Jari Aalto <jari.aalto@cante.net>
Date: Thu, 10 Sep 2009 19:55:38 +0300
Subject: [PATCH] lisp/rect.el: (number-rectangle): New user key binding C-x r N
Signed-off-by: Jari Aalto <jari.aalto@cante.net>
---
lisp/rect.el | 40 ++++++++++++++++++++++++++++++++++++++++
1 files changed, 40 insertions(+), 0 deletions(-)
diff --git a/lisp/rect.el b/lisp/rect.el
index eb188fc..6b63c81 100644
--- a/lisp/rect.el
+++ b/lisp/rect.el
@@ -39,6 +39,7 @@
;;;###autoload (define-key ctl-x-r-map "y" 'yank-rectangle)
;;;###autoload (define-key ctl-x-r-map "o" 'open-rectangle)
;;;###autoload (define-key ctl-x-r-map "t" 'string-rectangle)
+;;;###autoload (define-key ctl-x-r-map "N" 'number-rectangle)
;;; Code:
@@ -395,6 +396,45 @@ rectangle which were empty."
(delete-region pt (point))
(indent-to endcol)))))
+(defvar rectangle-number-line-counter nil
+ "Variable holding line numbering information.
+Initial value is set in function `rectangle-number-lines'
+and incremented for each line in `rectangle-number-line-callback'.")
+
+(defvar rectangle-number-line-format-history nil
+ "History variable that records previous format strings.")
+
+(defun rectangle-number-line-callback (start end format-string)
+ (move-to-column start t)
+ (setq rectangle-number-line-counter (+ rectangle-number-line-counter 1))
+ (insert (format format-string rectangle-number-line-counter)))
+
+(defun rectangle-number-lines (beg end start-at format &optional no-zero-padding)
+ "Insert numbers in front of lines in rectangle BEG END.
+
+START-AT specifices the first number to start at.
+FORMAT is format string where %i denotes inserted number.
+
+If prefix arg NO-ZERO-PADDING is non-nil, do not padd numbers
+with leading zeroes."
+ (interactive
+ (list
+ (region-beginning)
+ (region-end)
+ (if (functionp 'read-number)
+ (read-number "First number [1]: " 1)
+ (string-to-int (read-string "First number [1]: " nil nil "1")))
+ (read-string "Format: " "%i " 'rectangle-number-line-format-history)
+ current-prefix-arg))
+ (setq start-at (- start-at 1))
+ (unless no-zero-padding
+ (let* ((max (+ (count-lines beg end) start-at))
+ (longest (length (int-to-string (+ 1 max))))
+ (fmt (concat "%0" (int-to-string longest) "i")))
+ (setq format (replace-regexp-in-string "%i" fmt format))))
+ (setq rectangle-number-line-counter start-at)
+ (apply-on-rectangle 'rectangle-number-line-callback beg end format))
+
(provide 'rect)
;; arch-tag: 178847b3-1f50-4b03-83de-a6e911cc1d16
--
1.6.3.3
^ permalink raw reply related [flat|nested] 7+ messages in thread
[parent not found: <handler.4382.B.125249070423585.ack@emacsbugs.donarmstrong.com>]
* bug#4382: Acknowledgement ([PATCH] lisp/rect.el: (rectangle-number-lines): New user key binding C-x r N)
[not found] ` <handler.4382.B.125249070423585.ack@emacsbugs.donarmstrong.com>
@ 2009-09-12 15:46 ` Jari Aalto
0 siblings, 0 replies; 7+ messages in thread
From: Jari Aalto @ 2009-09-12 15:46 UTC (permalink / raw)
To: 4382
[-- Attachment #1: Type: text/plain, Size: 309 bytes --]
> RMS:
> Please include in your patch a change to etc/NEWS.
** The new command `number-rectangle' bound globally to `C-x r N' can
number selected lines in region. The optional zero padding, if the line
count is bigger than 9, is controlled by a prefix argument.
Patch below is against CVS as of 2009-09-12
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-etc-NEWS-The-new-command-number-rectangle.patch --]
[-- Type: text/x-diff, Size: 902 bytes --]
From 8909a2901ed5bc5be1d38590ec7e6795e473f323 Mon Sep 17 00:00:00 2001
From: Jari Aalto <jari.aalto@cante.net>
Date: Sat, 12 Sep 2009 18:45:56 +0300
Subject: [PATCH] etc/NEWS: The new command number-rectangle
Signed-off-by: Jari Aalto <jari.aalto@cante.net>
---
etc/NEWS | 4 ++++
1 files changed, 4 insertions(+), 0 deletions(-)
diff --git a/etc/NEWS b/etc/NEWS
index c677213..f726c8b 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -123,6 +123,10 @@ default-file-name-coding-system on Mac OS X.
\f
* Changes in Specialized Modes and Packages in Emacs 23.2
+** The new command `number-rectangle' bound globally to `C-x r N' can
+number selected lines in region. The optional zero padding, if the line
+count is bigger than 9, is controlled by a prefix argument.
+
** .calc.el and .abbrev_defs obey user-emacs-directory.
** Calc graphing commands (`g f' etc.) now work on MS-Windows,
--
1.6.3.3
^ permalink raw reply related [flat|nested] 7+ messages in thread
* bug#4382: [PATCH] lisp/rect.el: (rectangle-number-lines): New user key binding C-x r N
2009-09-09 10:04 bug#4382: [PATCH] lisp/rect.el: (rectangle-number-lines): New user key binding C-x r N Jari Aalto
2009-09-10 14:59 ` Richard Stallman
[not found] ` <handler.4382.B.125249070423585.ack@emacsbugs.donarmstrong.com>
@ 2009-09-16 10:52 ` Dan Nicolaescu
2 siblings, 0 replies; 7+ messages in thread
From: Dan Nicolaescu @ 2009-09-16 10:52 UTC (permalink / raw)
To: Jari Aalto; +Cc: 4382, Scott Evans
Jari Aalto <jari.aalto@cante.net> writes:
> Scott has just informaed me that his FSF assignment papers have been
> processed and cleared. Based on his work at
> http://www.antisleep.com/elisp/gse-number-rect.el I propose following
> new feature to be added to the rect.el package.
FWIW, I have had this code in my .emacs ever since it was posted to
gnu.emacs.sources, and I used it regularly. IMHO it is a nice addition
to the rectangle functions.
^ permalink raw reply [flat|nested] 7+ messages in thread
* bug#7538: [PATCH / wishlist] rect.el: (rectangle-number-lines) New user command C-x r N
@ 2010-12-03 9:49 Jari Aalto
2010-12-15 2:56 ` bug#4382: [PATCH] lisp/rect.el: (rectangle-number-lines): New user key binding " Chong Yidong
0 siblings, 1 reply; 7+ messages in thread
From: Jari Aalto @ 2010-12-03 9:49 UTC (permalink / raw)
To: 7538; +Cc: scott evans
[-- Attachment #1: Type: text/plain, Size: 982 bytes --]
Package: emacs
Version: 23.2+1-5.1
Severity: wishlist
X-debbugs-cc: Scott Evans <gse@antisleep.com>
The following patch is based on Scott Evans' work (2006):
http://www.antisleep.com/download/elisp/gse-number-rect.el
from where the relevant functionatily has been lifted.
- Used by permission of Scott (Email exchange, GPL).
- If my memory serves right, Scott applied 2009 for disclaimer papers.
Please verify the paper archives.
2010-12-03 Jari Aalto <jari.aalto@cante.net>
* rect.el (number-rectangle): New user function.
(rectangle-number-line-callback): New function.
(rectangle-number-line-format-history): New variable.
(rectangle-number-line-counter): New variable.
(define-key ctl-x-r-map "N" 'number-rectangle): New
user key binding. The basis of the rectangle numbering code was
lifted from gse-number-rect.el, orignally developed by Scott
Evans <gse@antisleep.com>. Used by permission (GPL).
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-etc-NEWS-Changes-in-Specialized-Modes-number-rectang.patch --]
[-- Type: text/x-diff, Size: 1172 bytes --]
From 70387b605961ac9ea35750195763738dc9d50d77 Mon Sep 17 00:00:00 2001
From: Jari Aalto <jari.aalto@cante.net>
Date: Fri, 3 Dec 2010 11:32:15 +0200
Subject: [PATCH] etc/NEWS: (Changes in Specialized Modes): number-rectangle
Organization: Private
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: 8bit
Signed-off-by: Jari Aalto <jari.aalto@cante.net>
---
etc/NEWS | 5 ++++-
1 files changed, 4 insertions(+), 1 deletions(-)
diff --git a/etc/NEWS b/etc/NEWS
index 5e16f45..f5afbf2 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -309,8 +309,11 @@ set `x-select-enable-clipboard' to nil.
** shell-mode can track your cwd by reading it from your prompt.
Just set shell-dir-cookie-re to an appropriate regexp.
-** Modula-2 mode provides auto-indentation.
+** New command `rectangle-number-lines' bound globally to `C-x r N'
+can number selected lines in region. The optional zero padding, if the
+line count is bigger than 9, is controlled by a prefix argument.
+** Modula-2 mode provides auto-indentation.
** latex-electric-env-pair-mode keeps \begin..\end matched on the fly.
** FIXME: xdg-open for browse-url and reportbug, 2010/08.
--
1.7.2.3
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #3: 0001-lisp-rect.el-number-rectangle-New-user-key-binding-C.patch --]
[-- Type: text/x-diff, Size: 2726 bytes --]
From 7fe34999c0926bf9a988cdd1a0913de3f41ab18d Mon Sep 17 00:00:00 2001
From: Jari Aalto <jari.aalto@cante.net>
Date: Fri, 3 Dec 2010 11:20:38 +0200
Subject: [PATCH] lisp/rect.el: (number-rectangle): New user key binding C-x r N
Organization: Private
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: 8bit
Signed-off-by: Jari Aalto <jari.aalto@cante.net>
---
lisp/rect.el | 40 ++++++++++++++++++++++++++++++++++++++++
1 files changed, 40 insertions(+), 0 deletions(-)
diff --git a/lisp/rect.el b/lisp/rect.el
index 6658408..f05af8d 100644
--- a/lisp/rect.el
+++ b/lisp/rect.el
@@ -40,6 +40,7 @@
;;;###autoload (define-key ctl-x-r-map "y" 'yank-rectangle)
;;;###autoload (define-key ctl-x-r-map "o" 'open-rectangle)
;;;###autoload (define-key ctl-x-r-map "t" 'string-rectangle)
+;;;###autoload (define-key ctl-x-r-map "N" 'rectangle-number-lines)
;;; Code:
@@ -396,6 +397,45 @@ rectangle which were empty."
(delete-region pt (point))
(indent-to endcol)))))
+(defvar rectangle-number-line-counter nil
+ "Variable holding line numbering information.
+Initial value is set in function `rectangle-number-lines'
+and incremented for each line in `rectangle-number-line-callback'.")
+
+(defvar rectangle-number-line-format-history nil
+ "History variable that records previous format strings.")
+
+(defun rectangle-number-line-callback (start end format-string)
+ (move-to-column start t)
+ (setq rectangle-number-line-counter (+ rectangle-number-line-counter 1))
+ (insert (format format-string rectangle-number-line-counter)))
+
+(defun rectangle-number-lines (beg end start-at format &optional no-zero-padding)
+ "Insert numbers in front of lines in rectangle BEG END.
+
+START-AT specifices the first number to start at.
+FORMAT is format string where %i denotes inserted number.
+
+If prefix arg NO-ZERO-PADDING is non-nil, do not padd numbers
+with leading zeroes."
+ (interactive
+ (list
+ (region-beginning)
+ (region-end)
+ (if (functionp 'read-number)
+ (read-number "First number [1]: " 1)
+ (string-to-int (read-string "First number [1]: " nil nil "1")))
+ (read-string "Format: " "%i " 'rectangle-number-line-format-history)
+ current-prefix-arg))
+ (setq start-at (- start-at 1))
+ (unless no-zero-padding
+ (let* ((max (+ (count-lines beg end) start-at))
+ (longest (length (int-to-string (+ 1 max))))
+ (fmt (concat "%0" (int-to-string longest) "i")))
+ (setq format (replace-regexp-in-string "%i" fmt format))))
+ (setq rectangle-number-line-counter start-at)
+ (apply-on-rectangle 'rectangle-number-line-callback beg end format))
+
(provide 'rect)
;; arch-tag: 178847b3-1f50-4b03-83de-a6e911cc1d16
--
1.7.2.3
[-- Attachment #4: Type: text/plain, Size: 559 bytes --]
-- System Information
Debian Release: squeeze/sid
APT Prefers testing
APT policy: (990, testing) (500, unstable) (1, experimental)
Architecture: amd64
Kernel: Linux picasso 2.6.32-5-amd64 #1 SMP Fri Sep 17 21:50:19 UTC 2010 x86_64 GNU/Linux
Locale: LANG=en_DK.UTF-8
-- Versions of packages `emacs depends on'.
Depends:
emacs23 23.2+1-5.1 GNU Emacs is the extensible self-documenting
emacs23-lucid 23.2+1-5.1 GNU Emacs is the extensible self-documenting
emacs23-nox 23.2+1-5.1 GNU Emacs is the extensible self-documenting
^ permalink raw reply related [flat|nested] 7+ messages in thread
end of thread, other threads:[~2010-12-15 2:56 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-09-09 10:04 bug#4382: [PATCH] lisp/rect.el: (rectangle-number-lines): New user key binding C-x r N Jari Aalto
2009-09-10 14:59 ` Richard Stallman
2009-09-10 16:59 ` Jari Aalto
2009-09-11 21:00 ` Richard Stallman
[not found] ` <handler.4382.B.125249070423585.ack@emacsbugs.donarmstrong.com>
2009-09-12 15:46 ` bug#4382: Acknowledgement ([PATCH] lisp/rect.el: (rectangle-number-lines): New user key binding C-x r N) Jari Aalto
2009-09-16 10:52 ` bug#4382: [PATCH] lisp/rect.el: (rectangle-number-lines): New user key binding C-x r N Dan Nicolaescu
-- strict thread matches above, loose matches on Subject: below --
2010-12-03 9:49 bug#7538: [PATCH / wishlist] rect.el: (rectangle-number-lines) New user command " Jari Aalto
2010-12-15 2:56 ` bug#4382: [PATCH] lisp/rect.el: (rectangle-number-lines): New user key binding " Chong Yidong
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.