Subject: 24.2.50; ibuffers mark commands are quirky
From: Andreas Politz <[email-masked]>
To: [email-masked]
Date: Sun, 04 Nov 2012 01:47:06 +0100
List-Id: <debbugs-submit.debbugs.gnu.org>

Hey Emacs guys !

I found some problems with ibuffers movement commands: The mark commands
in ibuffer use a "P" interactive spec and error on C-u prefix args. They
don't support negative arguments and the backwards unmarking behaviour
is non-standard (= dired).  The attached patch addresses these points.

-ap

diff -c -L /usr/share/emacs/24.2.50/lisp/ibuffer.el.gz -L \#\<buffer\ ibuffer.el.gz\> /tmp/jka-com2962CdI /tmp/buffer-content-2962cxU
*** /usr/share/emacs/24.2.50/lisp/ibuffer.el.gz
--- #<buffer ibuffer.el.gz>
***************
*** 1359,1382 ****
  (defun ibuffer-mark-forward (arg)
    "Mark the buffer on this line, and move forward ARG lines.
  If point is on a group name, this function operates on that group."
!   (interactive "P")
!   (ibuffer-mark-interactive arg ibuffer-marked-char 1))
  
  (defun ibuffer-unmark-forward (arg)
    "Unmark the buffer on this line, and move forward ARG lines.
  If point is on a group name, this function operates on that group."
!   (interactive "P")
!   (ibuffer-mark-interactive arg ?\s 1))
  
  (defun ibuffer-unmark-backward (arg)
    "Unmark the buffer on this line, and move backward ARG lines.
  If point is on a group name, this function operates on that group."
!   (interactive "P")
!   (ibuffer-mark-interactive arg ?\s -1))
  
! (defun ibuffer-mark-interactive (arg mark movement)
    (ibuffer-assert-ibuffer-mode)
    (or arg (setq arg 1))
    (ibuffer-forward-line 0)
    (ibuffer-aif (get-text-property (point) 'ibuffer-filter-group-name)
        (progn
--- 1359,1385 ----
  (defun ibuffer-mark-forward (arg)
    "Mark the buffer on this line, and move forward ARG lines.
  If point is on a group name, this function operates on that group."
!   (interactive "p")
!   (ibuffer-mark-interactive arg ibuffer-marked-char))
  
  (defun ibuffer-unmark-forward (arg)
    "Unmark the buffer on this line, and move forward ARG lines.
  If point is on a group name, this function operates on that group."
!   (interactive "p")
!   (ibuffer-mark-interactive arg ?\s))
  
  (defun ibuffer-unmark-backward (arg)
    "Unmark the buffer on this line, and move backward ARG lines.
  If point is on a group name, this function operates on that group."
!   (interactive "p")
!   (ibuffer-unmark-forward (- arg)))
  
! (defun ibuffer-mark-interactive (arg mark &optional movement)
    (ibuffer-assert-ibuffer-mode)
    (or arg (setq arg 1))
+   ;; deprecated movement argument
+   (when (and movement (< movement 0))
+     (setq arg (- arg)))
    (ibuffer-forward-line 0)
    (ibuffer-aif (get-text-property (point) 'ibuffer-filter-group-name)
        (progn
***************
*** 1386,1393 ****
      (let ((inhibit-read-only t))
        (while (> arg 0)
  	(ibuffer-set-mark mark)
! 	(ibuffer-forward-line movement t)
! 	(setq arg (1- arg))))))
  
  (defun ibuffer-set-mark (mark)
    (ibuffer-assert-ibuffer-mode)
--- 1389,1400 ----
      (let ((inhibit-read-only t))
        (while (> arg 0)
  	(ibuffer-set-mark mark)
! 	(ibuffer-forward-line 1 t)
! 	(setq arg (1- arg)))
!       (while (< arg 0)
! 	(ibuffer-forward-line -1 t)
! 	(ibuffer-set-mark mark)
! 	(setq arg (1+ arg))))))
  
  (defun ibuffer-set-mark (mark)
    (ibuffer-assert-ibuffer-mode)

Diff finished.  Sun Nov  4 01:32:54 2012