all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Simon Friis Vindum <simon@vindum.io>
To: emacs-devel@gnu.org
Subject: Re: #17555 24.4.50; 'mark-paragraph' does not allow extending the region backwards
Date: Thu, 12 May 2016 16:32:02 +0200	[thread overview]
Message-ID: <CAGqLG_t4A+FX+b596XniJOp9iebkqMfok-LzBUynK-gSxV2Z+g@mail.gmail.com> (raw)

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


             reply	other threads:[~2016-05-12 14:32 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-05-12 14:32 Simon Friis Vindum [this message]
2016-05-12 16:44 ` #17555 24.4.50; 'mark-paragraph' does not allow extending the region backwards Kaushal Modi
2016-05-12 17:06 ` Eli Zaretskii

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAGqLG_t4A+FX+b596XniJOp9iebkqMfok-LzBUynK-gSxV2Z+g@mail.gmail.com \
    --to=simon@vindum.io \
    --cc=emacs-devel@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.