From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: dieter@duenenhof-wilhelm.de (H. Dieter Wilhelm) Newsgroups: gmane.emacs.bugs Subject: bug#18847: 24.4; Inconsistent behaviour of M-h with negative arguments Date: Mon, 03 Nov 2014 18:56:00 +0100 Message-ID: <877fzc418v.fsf@vsl28t2g.ww011> References: <877fzmqunb.fsf@vsl28t2g.ww011> <87oasvq1ja.fsf@vsl28t2g.ww011> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1415037445 345 80.91.229.3 (3 Nov 2014 17:57:25 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Mon, 3 Nov 2014 17:57:25 +0000 (UTC) Cc: 18847@debbugs.gnu.org To: Stefan Monnier Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Mon Nov 03 18:57:17 2014 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1XlLsT-00017k-9q for geb-bug-gnu-emacs@m.gmane.org; Mon, 03 Nov 2014 18:57:17 +0100 Original-Received: from localhost ([::1]:36569 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XlLsS-00023Q-Uj for geb-bug-gnu-emacs@m.gmane.org; Mon, 03 Nov 2014 12:57:16 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:45126) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XlLsJ-0001rN-Ju for bug-gnu-emacs@gnu.org; Mon, 03 Nov 2014 12:57:12 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XlLsE-00010S-De for bug-gnu-emacs@gnu.org; Mon, 03 Nov 2014 12:57:07 -0500 Original-Received: from debbugs.gnu.org ([140.186.70.43]:50573) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XlLsE-00010M-9M for bug-gnu-emacs@gnu.org; Mon, 03 Nov 2014 12:57:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.80) (envelope-from ) id 1XlLsD-0005ya-UL for bug-gnu-emacs@gnu.org; Mon, 03 Nov 2014 12:57:02 -0500 X-Loop: help-debbugs@gnu.org In-Reply-To: <877fzmqunb.fsf@vsl28t2g.ww011> Resent-From: dieter@duenenhof-wilhelm.de (H. Dieter Wilhelm) Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Mon, 03 Nov 2014 17:57:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 18847 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 18847-submit@debbugs.gnu.org id=B18847.141503737322905 (code B ref 18847); Mon, 03 Nov 2014 17:57:01 +0000 Original-Received: (at 18847) by debbugs.gnu.org; 3 Nov 2014 17:56:13 +0000 Original-Received: from localhost ([127.0.0.1]:47786 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1XlLrQ-0005xM-UO for submit@debbugs.gnu.org; Mon, 03 Nov 2014 12:56:13 -0500 Original-Received: from mail-lb0-f181.google.com ([209.85.217.181]:61986) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1XlLrN-0005x7-VO for 18847@debbugs.gnu.org; Mon, 03 Nov 2014 12:56:10 -0500 Original-Received: by mail-lb0-f181.google.com with SMTP id l4so3087116lbv.12 for <18847@debbugs.gnu.org>; Mon, 03 Nov 2014 09:56:03 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:from:to:cc:subject:references:date:message-id:user-agent :mime-version:content-type; bh=QekHHlpvd9dEsoXZ6nUoP7Bz8kaF2nnkxo0Mi1t98do=; b=TPi/YjuzC+f97xrgsLScBWEqe7KmbkNAsc63HiO4K2EXNy41tn746dyWF64OGZoZwR X+3rsAQtIssZbNz2wMcaQZ3/IcQis/X8M9TObcm/lZ1Gakmutqw+x8o2OlvfBlrPZu9n yKhe4aRV1cGvSGO0gV+s/ypvVB6CCkPmjMHsmDlQBIQclSf81M+39NpGpflHIzcIDOJA vpUAE6YKVfaO24VMsjvUqsNuRlMA42MnqjfCUHCBksG3kE7XffUPoazeSib9lcAHu/iU 6t8hJiwvYO8CVSFtIJ+pdCBUKoEdRrPxZjNoq3Lb2+4eAD29DkBvTRZkr2EzeaWpdQvV 8S2g== X-Received: by 10.112.169.106 with SMTP id ad10mr52740262lbc.13.1415037363606; Mon, 03 Nov 2014 09:56:03 -0800 (PST) Original-Received: from vsl28t2g.ww011 (p4FD4F4FD.dip0.t-ipconnect.de. [79.212.244.253]) by mx.google.com with ESMTPSA id or5sm8191666lbb.42.2014.11.03.09.56.02 for (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Mon, 03 Nov 2014 09:56:03 -0800 (PST) User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.4 (gnu/linux) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 140.186.70.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:95438 Stefan Monnier writes: > [ Be careful to keep 18847@debbugs.gnu.org in the Cc, please. ] Sorry, I overlooked the Cc field. .... >> 2) When applying M-h (or any other marking command) at the end of a >> buffer (at least interactively, I failed to address this), the right >> thing to do is marking (a) previous element(s). I would like to know >> if you find this a good idea. > > I have no opinion on this, I never use M-h myself. Interesting, no M-h! Anyway, in the meantime I tested M-h more thoroughly in these borderline cases and I think its behaviour is actually not correct. I suggest to separate this issue and possible enhancements from the current subject. >> 3) M-h (C-M-h and C-x C-p ) differ from C-@ and C-M-@ that they are >> always marking (a) whole element(s). I wanted to clarify in the >> documentation string that a marking from point is also achievable >> with M-h. > > So this part is just a docstring change, right? Exactly. >> 4) M-h does signal an error applying zero as an argument, the other >> marking commands just ignore zero, so I thought a message might be a >> good compromise to the current state... > > I have no opinion on this one either. It doesn't seem terribly > important, so reducing discrepancies in this case might be the > dominating factor. Right, I dropped the zero argument message. (But still inhibited M-h to activate the mark in this situation.) Thank you for your patience Dieter (defun mark-paragraph (&optional arg allow-extend) "Put point at beginning of this paragraph, mark at end. The paragraph marked is the one that contains point or follows point. With argument ARG, puts mark at the end of this or a following paragraph, so that the number of paragraphs marked equals ARG. If ARG is negative, point is put at the end of this paragraph, mark is put at the 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 region already marked. This also means when activating the mark immediately before using this command, the current paragraph is only marked from point." (interactive "P\np") (let ((numeric-arg (prefix-numeric-value arg))) (cond ((zerop numeric-arg)) ((and allow-extend (or (and (eq last-command this-command) mark-active) (region-active-p))) (if arg (setq arg numeric-arg) (if (< (mark) (point)) (setq arg -1) (setq arg 1))) (set-mark (save-excursion (goto-char (mark)) (forward-paragraph arg) (point)))) (t (forward-paragraph numeric-arg) (push-mark nil t t) (backward-paragraph numeric-arg))))) diff --git a/lisp/textmodes/paragraphs.el b/lisp/textmodes/paragraphs.el index 3e77d37..e1a735d 100644 --- a/lisp/textmodes/paragraphs.el +++ b/lisp/textmodes/paragraphs.el @@ -370,34 +370,47 @@ See `forward-paragraph' for more information." (forward-paragraph (- arg))) (defun mark-paragraph (&optional arg allow-extend) - "Put point at beginning of this paragraph, mark at end. -The paragraph marked is the one that contains point or follows point. - -With argument ARG, puts mark at end of a following paragraph, so that -the number of paragraphs marked equals ARG. - -If ARG is negative, point is put at end of this paragraph, mark is put -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) - (error "Cannot mark zero paragraphs")) - (cond ((and allow-extend - (or (and (eq last-command this-command) (mark t)) - (and transient-mark-mode mark-active))) - (set-mark - (save-excursion - (goto-char (mark)) - (forward-paragraph arg) - (point)))) - (t - (forward-paragraph arg) - (push-mark nil t t) - (backward-paragraph arg)))) + "Put mark at beginning of this paragraph, point at end. +The paragraph marked is the one that contains point or follows +point. + +With argument ARG, puts mark at the end of this or a following +paragraph, so that the number of paragraphs marked equals ARG. + +If ARG is negative, point is put at the beginning of this +paragraph, mark is put at the end of this or a previous +paragraph. + +Interactively, if this command is repeated or (in Transient Mark +Mode) if the mark is active, it marks the next ARG paragraphs +after the region already marked. This also means when activating +the mark immediately before using this command, the current +paragraph is only marked from point." + (interactive "P\np") + (let ((numeric-arg (prefix-numeric-value arg))) + (cond ((eobp) ; smart-aleck? + (backward-paragraph (abs numeric-arg)) + (push-mark nil t t) + (forward-paragraph (abs numeric-arg))) + ((and allow-extend + (or (region-active-p) + (and (eq last-command this-command) mark-active))) + (if arg + (setq arg numeric-arg) + (if (< (mark) (point)) + (setq arg -1) + (setq arg 1))) + (set-mark + (save-excursion + (goto-char (mark)) + (forward-paragraph arg) + (point)))) + ((zerop numeric-arg) + (message "Will not mark zero paragraphs.")) + (t + (forward-paragraph numeric-arg) + (push-mark nil t t) + (backward-paragraph numeric-arg))))) (defun kill-paragraph (arg) "Kill forward to end of paragraph. -- Best wishes H. Dieter Wilhelm Darmstadt, Germany