summaryrefslogtreecommitdiff
path: root/lisp/ibuffer.el
diff options
context:
space:
mode:
authorTino Calancha <tino.calancha@gmail.com>2016-10-03 21:16:00 +0900
committerTino Calancha <tino.calancha@gmail.com>2016-10-03 21:16:00 +0900
commita7e9d1cce3f935dbe9f242f0bf2dbf34f5919952 (patch)
tree93bb7cf3489fab90f3e03852d03a311a707c0796 /lisp/ibuffer.el
parent3b6eb9489d03e5ecc60e487e8eb340e34942825c (diff)
downloademacs-a7e9d1cce3f935dbe9f242f0bf2dbf34f5919952.tar.gz
Ibuffer: 'w' and 'B' default to buffer at current line
See discussion in: https://lists.gnu.org/archive/html/emacs-devel/2016-09/msg00384.html * lisp/ibuffer.el (ibuffer--near-buffers): New defun; return buffers near current line. * lisp/ibuf-ext.el (ibuffer-copy-buffername-as-kill): Use it. Add argument ARG; if a non-zero integer, return next ARG buffers. Otherwise return the marked buffers. If there are not marked buffers, return buffer at current line without prompting the user. Use ibuffer-get-marked-buffers instead of ibuffer-map-marked-lines. Append to kill ring when last command was a kill-region. (ibuffer-copy-filename-as-kill): Idem. Simplify the code. Use ibuffer-buffer-file-name instead of buffer-file-name to include buffers in Dired mode.
Diffstat (limited to 'lisp/ibuffer.el')
-rw-r--r--lisp/ibuffer.el10
1 files changed, 10 insertions, 0 deletions
diff --git a/lisp/ibuffer.el b/lisp/ibuffer.el
index e9655358c26..9becfc9fc78 100644
--- a/lisp/ibuffer.el
+++ b/lisp/ibuffer.el
@@ -2022,6 +2022,16 @@ the buffer object itself and the current mark symbol."
(ibuffer-forward-line 0)
(ibuffer-forward-line (1- target-line-offset))))))
+;; Return buffers around current line.
+(defun ibuffer--near-buffers (n)
+ (delq nil
+ (mapcar
+ (lambda (x)
+ (car (get-text-property
+ (line-beginning-position (if (natnump n) x (- (1- x))))
+ 'ibuffer-properties)))
+ (number-sequence 1 (abs n)))))
+
(defun ibuffer-get-marked-buffers ()
"Return a list of buffer objects currently marked."
(delq nil