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.help Subject: Re: Inconsistencies between marking commands M-h, C-M-h and C-@ Date: Thu, 09 Oct 2014 11:36:53 +0200 Organization: The Church of Emacs Message-ID: <87fvexd1oq.fsf@vsl28t2g.ww011> References: <8761fusgbs.fsf@vsl28t2g.ww011> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1412847463 9542 80.91.229.3 (9 Oct 2014 09:37:43 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Thu, 9 Oct 2014 09:37:43 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Thu Oct 09 11:37:36 2014 Return-path: Envelope-to: geh-help-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 1XcAAB-0004ke-LN for geh-help-gnu-emacs@m.gmane.org; Thu, 09 Oct 2014 11:37:35 +0200 Original-Received: from localhost ([::1]:41332 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XcAAB-00074x-8r for geh-help-gnu-emacs@m.gmane.org; Thu, 09 Oct 2014 05:37:35 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:52143) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XcA9s-0006yy-6L for help-gnu-emacs@gnu.org; Thu, 09 Oct 2014 05:37:22 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XcA9l-0005T0-CW for help-gnu-emacs@gnu.org; Thu, 09 Oct 2014 05:37:16 -0400 Original-Received: from plane.gmane.org ([80.91.229.3]:37365) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XcA9l-0005Ss-4C for help-gnu-emacs@gnu.org; Thu, 09 Oct 2014 05:37:09 -0400 Original-Received: from list by plane.gmane.org with local (Exim 4.69) (envelope-from ) id 1XcA9i-0004XK-Pc for help-gnu-emacs@gnu.org; Thu, 09 Oct 2014 11:37:06 +0200 Original-Received: from p57acf88a.dip0.t-ipconnect.de ([87.172.248.138]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Thu, 09 Oct 2014 11:37:06 +0200 Original-Received: from dieter by p57acf88a.dip0.t-ipconnect.de with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Thu, 09 Oct 2014 11:37:06 +0200 X-Injected-Via-Gmane: http://gmane.org/ Original-Lines: 174 Original-X-Complaints-To: usenet@ger.gmane.org X-Gmane-NNTP-Posting-Host: p57acf88a.dip0.t-ipconnect.de User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3.94 (gnu/linux) Cancel-Lock: sha1:xc7+3wHSERnEcc/gct2UGUOrtho= X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 80.91.229.3 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:100347 Archived-At: Sorry for inundating this list :-/ but I forgot to mention the other, arguably also distracting, differences: Handling of a 0 (zero) argument ------------------------------ M-h is actually indicating an error while C-SPC and C-@ do mark nothing, wheras C-M-h is ignoring zero... Moreover M-h is changing its behaviour (unexpectedly) when subsequently applying another M-h after using it with a zero argument! Please compare: M-0 M-h M-h with just M-h and while I'm at it: Handling of white-spaces ------------------------------ When in whitespaces or empty lines M-h currently ignores them (for the first paragraph) while C-M-h and C-@ encompass them in their marking. I'm not so sure what to do with the white-space difference, so I'd leave it at the current state but I feel the error signal is too severe: (defun mark-paragraph (&optional arg allow-extend) "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 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 ones already marked. This means when activating the mark before using this command, the current paragraph is only marked from point." (interactive "P\np") (cond ((zerop (prefix-numeric-value arg)) ;argument is zero (message "Will not mark zero paragraphs.")) ((and allow-extend ;we already called this function (or (and (eq last-command this-command) (mark t) mark-active) (and transient-mark-mode mark-active))) (if arg (setq arg (prefix-numeric-value arg)) (if (< (mark) (point)) (setq arg -1) (setq arg 1))) (set-mark (save-excursion (if mark-active (goto-char (mark))) (forward-paragraph arg) (point)))) (t ;we are in an empty line or a paragraph (if arg (setq arg (prefix-numeric-value arg)) (setq arg 1)) (forward-paragraph arg) (push-mark nil t t) (backward-paragraph arg)))) And, sorry, in my previous mail I meant C-M-@ (mark-sexp) not C-M-h (mark-defun). :-( Dieter dieter@duenenhof-wilhelm.de (H. Dieter Wilhelm) writes: > Hello keyboarder, ;-) > > Marking range > ------------- > the behaviour of M-h (mark-paragraph) reflects better its name because > it marks full paragraphs, whereas M-C-h and C-@ are only marking from > the current point onward regexps and words, respectively. > > Surely I can live with this difference, but, still, mark-word doesn't > *mark a word* when it's in a word! ... > > Sequential calls > ----------------- > When using the commands in a sequence, with M-h it is not possible to > mark additionally backwards paragraphs without explicitly giving > negative arguments. Please compare: > > M-- C-@ C-@ C-@ ... and > > M-- C-@ M-- C-@ M-- C-@ ... with > > M-- M-h M-h M-h ... and > > M-- M-h M-- M-h M-- M-h ... > > The following version of mark-paragraph is mitigating these differences > and highlights its behaviour when the mark is activated before applying > M-h. Do you find this stuff acceptable, worthwhile, nitpicking, ...? > > (defun mark-paragraph (&optional arg allow-extend) > "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 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 ones already marked. This means when activating the > mark before using this command, the current paragraph is only > marked from point. > " > (interactive "P\np") > (cond ((zerop (prefix-numeric-value arg)) ;argument is zero > (forward-paragraph) > (push-mark nil t nil) > (backward-paragraph) > (message "Will not activate mark for zero paragraphs.")) > ((and allow-extend ;we already called this function > (or (and (eq last-command this-command) (mark t)) > (and transient-mark-mode mark-active))) > (if arg > (setq arg (prefix-numeric-value arg)) > (if (< (mark) (point)) > (setq arg -1) > (setq arg 1))) > (set-mark > (save-excursion > (if mark-active (goto-char (mark))) > (forward-paragraph arg) > (point)))) > (t ;we are before or within a paragraph > (if arg > (setq arg (prefix-numeric-value arg)) > (setq arg 1)) > (forward-paragraph arg) > (push-mark nil t t) > (backward-paragraph arg)))) > > A last point > ------------ > I think it makes sense when the point remains as close from the point > where the marking commands are called from. But I find myself often > marking paragraphs which span outside of the window and I do not see how > far M-h is marking or whether it might be worthwhile to apply it > additionally. Yes, I could use e. g. C-SPC and M-} but M-h is often the > fastest starting point. > > Privately I'm using a version of M-h which is checking whether the mark > is outside the window and then exchanging point and mark. I know this > is a rather disruptive behaviour but find it helpful in my work-flow, it > feels like a natural extension of M-h. When somebody is interested I'd > present it to you. Or do you prefer a different work-flow or a better > way of structural marking? ;-) > > Dieter -- Best wishes H. Dieter Wilhelm Darmstadt, Germany