all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Inconsistencies between marking commands M-h, C-M-h and C-@
@ 2014-10-08 15:59 H. Dieter Wilhelm
  2014-10-09  9:36 ` H. Dieter Wilhelm
  0 siblings, 1 reply; 2+ messages in thread
From: H. Dieter Wilhelm @ 2014-10-08 15:59 UTC (permalink / raw)
  To: help-gnu-emacs

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




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

end of thread, other threads:[~2014-10-09  9:36 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-10-08 15:59 Inconsistencies between marking commands M-h, C-M-h and C-@ H. Dieter Wilhelm
2014-10-09  9:36 ` H. Dieter Wilhelm

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.