branch: externals/embark
commit 926f1028dff0ca0dc4adcc24436124f579fc0ec3
Author: Daniel Mendler <m...@daniel-mendler.de>
Commit: Daniel Mendler <m...@daniel-mendler.de>

    Add embark-target-buffer-at-point
    
    Works in ibuffer-mode and Buffer-menu-mode.
    
    As discussed in #753
---
 embark.el | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/embark.el b/embark.el
index 913f8bdd5c..61350d68cf 100644
--- a/embark.el
+++ b/embark.el
@@ -176,6 +176,7 @@ or a list of such symbols."
     embark-target-email-at-point
     embark-target-url-at-point
     embark-target-file-at-point
+    embark-target-buffer-at-point
     embark-target-custom-variable-at-point
     embark-target-identifier-at-point
     embark-target-guess-file-at-point
@@ -756,6 +757,14 @@ following exceptions:
     (when file
       `(file ,(abbreviate-file-name (expand-file-name file)) ,@bounds))))
 
+(defun embark-target-buffer-at-point ()
+  "Target buffer at point in Ibuffer or the buffer menu."
+  (when-let ((bol (pos-bol))
+             (buf (or (car (get-text-property bol 'ibuffer-properties))
+                      (get-text-property bol 'tabulated-list-id)))
+             ((buffer-live-p buf)))
+    `(buffer ,(buffer-name buf) ,bol . ,(pos-eol))))
+
 (defun embark-target-package-at-point ()
   "Target the package on the current line in a packages buffer."
   (when (derived-mode-p 'package-menu-mode)

Reply via email to