all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Re: #17555 24.4.50; 'mark-paragraph' does not allow extending the region backwards
@ 2016-05-12 14:32 Simon Friis Vindum
  2016-05-12 16:44 ` Kaushal Modi
  2016-05-12 17:06 ` Eli Zaretskii
  0 siblings, 2 replies; 3+ messages in thread
From: Simon Friis Vindum @ 2016-05-12 14:32 UTC (permalink / raw)
  To: emacs-devel

[-- Attachment #1: Type: text/plain, Size: 494 bytes --]

This small patch fixes the bug #17555. This increases the consistency
of `mark-paragraph` with `mark-word` and `mark-sexp`.

Currently "C-- M-h M-h" will end up selecting nothing since repeating
`mark-paragraph` always expands forwards even if `mark-paragraph` was
initially invoked with a negative prefix argument.

This is my first patch to Emacs. I have not signed the papers
assigning copyright to FSF. I would like to do so but I cannot figure
out how to.

Kind regards
Simon Friis Vindum

[-- Attachment #2: 0001-Mark-paragraph-will-extend-backwards-Bug-17555.patch --]
[-- Type: text/x-patch, Size: 1544 bytes --]

From 6f57c44850a330b7e3eacd91e2df28b71caffb36 Mon Sep 17 00:00:00 2001
From: paldepind <simonfv@gmail.com>
Date: Thu, 12 May 2016 16:08:09 +0200
Subject: [PATCH] Mark paragraph will extend backwards (Bug#17555)

---
 lisp/textmodes/paragraphs.el | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/lisp/textmodes/paragraphs.el b/lisp/textmodes/paragraphs.el
index b7523ca..cc17941 100644
--- a/lisp/textmodes/paragraphs.el
+++ b/lisp/textmodes/paragraphs.el
@@ -382,22 +382,23 @@ at beginning of this or a previous paragraph.
 Interactively (or if ALLOW-EXTEND is non-nil), if this command is
 repeated or (in Transient Mark mode) if the mark is active,
 it marks the next ARG paragraphs after the ones already marked."
-  (interactive "p\np")
-  (unless arg (setq arg 1))
-  (when (zerop arg)
+  (interactive "P\np")
+  (when (and arg (zerop (prefix-numeric-value arg)))
     (error "Cannot mark zero paragraphs"))
   (cond ((and allow-extend
 	      (or (and (eq last-command this-command) (mark t))
 		  (and transient-mark-mode mark-active)))
+         (setq arg (if arg (prefix-numeric-value arg)
+		     (if (< (mark) (point)) -1 1)))
 	 (set-mark
 	  (save-excursion
 	    (goto-char (mark))
 	    (forward-paragraph arg)
 	    (point))))
 	(t
-	 (forward-paragraph arg)
+	 (forward-paragraph (prefix-numeric-value arg))
 	 (push-mark nil t t)
-	 (backward-paragraph arg))))
+	 (backward-paragraph (prefix-numeric-value arg)))))
 
 (defun kill-paragraph (arg)
   "Kill forward to end of paragraph.
-- 
2.8.2


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

end of thread, other threads:[~2016-05-12 17:06 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-05-12 14:32 #17555 24.4.50; 'mark-paragraph' does not allow extending the region backwards Simon Friis Vindum
2016-05-12 16:44 ` Kaushal Modi
2016-05-12 17:06 ` Eli Zaretskii

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.