all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* keep|flush-lines, how-many to be used backward.
@ 2007-09-24 16:08 Michaël Cadilhac
  2007-09-24 17:27 ` Drew Adams
                   ` (2 more replies)
  0 siblings, 3 replies; 19+ messages in thread
From: Michaël Cadilhac @ 2007-09-24 16:08 UTC (permalink / raw)
  To: emacs-devel


[-- Attachment #1.1.1: Type: text/plain, Size: 299 bytes --]

I've been using this for a few days, and I find it quite useful.  It may
be good to install.

The effect: C-u M-x how-many RET is how-many'ing in the text *before*
point.  Same for C-u M-x keep-lines.

If this is not the right thing to do for such a feature, just say it,
I'll not insist too much.


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1.1.2: replace.patch --]
[-- Type: text/x-patch, Size: 4526 bytes --]

--- replace.el	26 Jul 2007 07:26:32 +0200	1.259
+++ replace.el	24 Sep 2007 18:04:34 +0200	
@@ -525,10 +525,15 @@
 
 (defun keep-lines-read-args (prompt)
   "Read arguments for `keep-lines' and friends.
-Prompt for a regexp with PROMPT.
+Prompt for a regexp with PROMPT followed by some information and a colon.
 Value is a list, (REGEXP)."
-  (list (read-from-minibuffer prompt nil nil nil
-			      'regexp-history nil t)
+  (list (read-from-minibuffer (concat prompt
+				      (if (and transient-mark-mode mark-active)
+					  " in the region: "
+					(if current-prefix-arg
+					    " backward: "
+					  ": ")))
+			      nil nil nil 'regexp-history nil t)
 	nil nil t))
 
 (defun keep-lines (regexp &optional rstart rend interactive)
@@ -547,7 +552,8 @@
 
 Interactively, in Transient Mark mode when the mark is active, operate
 on all lines whose accessible part is entirely contained in the region.
-Otherwise, the command applies to all lines starting after point.
+Otherwise, the command applies to all lines starting after point (or before
+point if a prefix argument is provided).
 When calling this function from Lisp, you can pretend that it was
 called interactively by passing a non-nil INTERACTIVE argument.
 
@@ -558,7 +564,7 @@
   (interactive
    (progn
      (barf-if-buffer-read-only)
-     (keep-lines-read-args "Keep lines (containing match for regexp): ")))
+     (keep-lines-read-args "Keep lines (containing match for regexp)")))
   (if rstart
       (progn
 	(goto-char (min rstart rend))
@@ -576,8 +582,8 @@
 		     (unless (or (bolp) (eobp))
 		       (forward-line 0))
 		     (point-marker)))
-      (setq rstart (point)
-	    rend (point-max-marker)))
+      (setq rstart (if current-prefix-arg (point-min) (point))
+	    rend (if current-prefix-arg (point-marker) (point-max-marker))))
     (goto-char rstart))
   (save-excursion
     (or (bolp) (forward-line 1))
@@ -620,9 +626,10 @@
 
 Interactively, in Transient Mark mode when the mark is active, operate
 on the contents of the region.  Otherwise, operate from point to the
-end of (the accessible portion of) the buffer.  When calling this function
-from Lisp, you can pretend that it was called interactively by passing
-a non-nil INTERACTIVE argument.
+end of (the accessible portion of) the buffer (or its beginning if a prefix
+argument is provided).
+When calling this function from Lisp, you can pretend that it was called
+interactively by passing a non-nil INTERACTIVE argument.
 
 If a match is split across lines, all the lines it lies in are deleted.
 They are deleted _before_ looking for the next match.  Hence, a match
@@ -631,7 +638,7 @@
   (interactive
    (progn
      (barf-if-buffer-read-only)
-     (keep-lines-read-args "Flush lines (containing match for regexp): ")))
+     (keep-lines-read-args "Flush lines (containing match for regexp)")))
   (if rstart
       (progn
 	(goto-char (min rstart rend))
@@ -639,8 +646,8 @@
     (if (and interactive transient-mark-mode mark-active)
 	(setq rstart (region-beginning)
 	      rend (copy-marker (region-end)))
-      (setq rstart (point)
-	    rend (point-max-marker)))
+      (setq rstart (if current-prefix-arg (point-min) (point))
+	    rend (if current-prefix-arg (point-marker) (point-max-marker))))
     (goto-char rstart))
   (let ((case-fold-search (and case-fold-search
 			       (isearch-no-upper-case-p regexp t))))
@@ -668,14 +675,16 @@
 
 Interactively, in Transient Mark mode when the mark is active, operate
 on the contents of the region.  Otherwise, operate from point to the
-end of (the accessible portion of) the buffer.
+end of (the accessible portion of) the buffer (or its beginning if a
+prefix argument is provided).
 
 This function starts looking for the next match from the end of
 the previous match.  Hence, it ignores matches that overlap
 a previously found match."
 
   (interactive
-   (keep-lines-read-args "How many matches for (regexp): "))
+   (keep-lines-read-args "How many matches for (regexp)"))
+
   (save-excursion
     (if rstart
 	(progn
@@ -684,8 +693,8 @@
       (if (and interactive transient-mark-mode mark-active)
 	  (setq rstart (region-beginning)
 		rend (region-end))
-	(setq rstart (point)
-	      rend (point-max)))
+	(setq rstart (if current-prefix-arg (point-min) (point))
+	      rend (if current-prefix-arg (point) (point-max))))
       (goto-char rstart))
     (let ((count 0)
 	  opoint

[-- Attachment #1.1.3: Type: text/plain, Size: 329 bytes --]



-- 
 |   Michaël `Micha' Cadilhac       |  In a World without Walls and Fences,  |
 |   http://michael.cadilhac.name   |     who needs Windows and Gates?       |
 |   JID/MSN:                       |          -- Dino Esposito              |
 `----  michael.cadilhac@gmail.com  |                                   -  --'

[-- Attachment #1.2: Type: application/pgp-signature, Size: 188 bytes --]

[-- Attachment #2: Type: text/plain, Size: 142 bytes --]

_______________________________________________
Emacs-devel mailing list
Emacs-devel@gnu.org
http://lists.gnu.org/mailman/listinfo/emacs-devel

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

end of thread, other threads:[~2007-09-30  2:18 UTC | newest]

Thread overview: 19+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-09-24 16:08 keep|flush-lines, how-many to be used backward Michaël Cadilhac
2007-09-24 17:27 ` Drew Adams
2007-09-24 17:42   ` Michaël Cadilhac
2007-09-25 14:10     ` Stefan Monnier
2007-09-25 14:36       ` Michaël Cadilhac
2007-09-26  5:01         ` Stefan Monnier
2007-09-25 10:44 ` Richard Stallman
2007-09-25 20:39 ` Michaël Cadilhac
2007-09-25 20:56   ` Juri Linkov
2007-09-25 21:01     ` Michaël Cadilhac
2007-09-25 21:49       ` Juri Linkov
2007-09-28  9:32         ` Michaël Cadilhac
2007-09-28 10:52           ` Robert J. Chassell
2007-09-28 10:59             ` Michaël Cadilhac
2007-09-29 16:10             ` Richard Stallman
2007-09-28 15:50           ` Drew Adams
2007-09-28 22:25           ` Robert J. Chassell
2007-09-29 22:48           ` Juri Linkov
2007-09-30  2:18             ` Drew Adams

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.