unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: dieter@duenenhof-wilhelm.de (H. Dieter Wilhelm)
To: 18847@debbugs.gnu.org
Subject: bug#18847: 24.4; Inconsistent behaviour of M-h with negative arguments
Date: Mon, 27 Oct 2014 08:37:44 +0100	[thread overview]
Message-ID: <8738aaq7xz.fsf@vsl28t2g.ww011> (raw)
In-Reply-To: <877fzmqunb.fsf@vsl28t2g.ww011>

dieter@duenenhof-wilhelm.de (H. Dieter Wilhelm) writes:

> Hello,
>
> please try M-- M-h M-h M-h.
>
> below some paragraphs.  The behaviour is not in line with the other
> marking commands like M-@, ...
>
> Here's a suggestion and a matching patch:

I'm sorry, I overlooked a special case:

(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 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)))))


diff -c /usr/local/src/emacs-24.4/lisp/textmodes/paragraphs.el /usr/local/src/emacs/lisp/textmodes/paragraphs.el
*** /usr/local/src/emacs-24.4/lisp/textmodes/paragraphs.el	2014-03-21 06:34:40.000000000 +0100
--- /usr/local/src/emacs/lisp/textmodes/paragraphs.el	2014-10-27 08:31:27.457755345 +0100
***************
*** 370,403 ****
    (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))))
  
  (defun kill-paragraph (arg)
    "Kill forward to end of paragraph.
--- 370,416 ----
    (forward-paragraph (- arg)))
  
  (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 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.

Diff finished.  Mon Oct 27 08:31:56 2014



> (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")
>   (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 ;we already called this function or have
> 			     ;a (possibly empty) region
> 		(or (eq last-command this-command)
> 		    (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))))
> 	  ((zerop numeric-arg)		
> 	   (message "Will not mark zero paragraphs."))
> 	  (t
> 	   (forward-paragraph numeric-arg)
> 	   (push-mark nil t t)
> 	   (backward-paragraph numeric-arg)))))
>
>
> Thank you for your troubles!
>
> diff -c /usr/local/src/emacs-24.4/lisp/textmodes/paragraphs.el /usr/local/src/emacs/lisp/textmodes/paragraphs.el
> *** /usr/local/src/emacs-24.4/lisp/textmodes/paragraphs.el	2014-03-21 06:34:40.000000000 +0100
> --- /usr/local/src/emacs/lisp/textmodes/paragraphs.el	2014-10-27 00:22:41.874845901 +0100
> ***************
> *** 370,403 ****
>     (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))))
>   
>   (defun kill-paragraph (arg)
>     "Kill forward to end of paragraph.
> --- 370,417 ----
>     (forward-paragraph (- arg)))
>   
>   (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")
> !   (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 ;we already called this function or have
> ! 			     ;a (possibly empty) region
> ! 		(or (eq last-command this-command)
> ! 		    (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))))
> ! 	  ((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.
>
> Diff finished.  Mon Oct 27 00:22:49 2014

-- 
Best wishes
H. Dieter Wilhelm
Darmstadt, Germany






  reply	other threads:[~2014-10-27  7:37 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-10-26 23:27 bug#18847: 24.4; Inconsistent behaviour of M-h with negative arguments H. Dieter Wilhelm
2014-10-27  7:37 ` H. Dieter Wilhelm [this message]
2014-10-28 17:04 ` Stefan Monnier
     [not found]   ` <87oasvq1ja.fsf@vsl28t2g.ww011>
2014-10-30 16:35     ` Stefan Monnier
2014-11-03 17:56       ` H. Dieter Wilhelm
2014-11-15 19:13         ` H. Dieter Wilhelm
2020-08-13  9:51           ` Lars Ingebrigtsen

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

  List information: https://www.gnu.org/software/emacs/

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

  git send-email \
    --in-reply-to=8738aaq7xz.fsf@vsl28t2g.ww011 \
    --to=dieter@duenenhof-wilhelm.de \
    --cc=18847@debbugs.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 public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).