emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

master e88be49 3/3: image-dired: Add support for bookmark.el


From: Stefan Kangas
Subject: master e88be49 3/3: image-dired: Add support for bookmark.el
Date: Wed, 27 Oct 2021 00:37:02 -0400 (EDT)

branch: master
commit e88be49b9db51f36ef2b6b3fc6716cd02203775f
Author: Stefan Kangas <stefan@marxist.se>
Commit: Stefan Kangas <stefan@marxist.se>

    image-dired: Add support for bookmark.el
    
    * lisp/image-dired.el (image-dired-thumbnail-mode): Add bookmark.el support.
    (bookmark-make-record-default, bookmark-prop-get): Declare.
    (image-dired-bookmark-name, image-dired-bookmark-make-record)
    (image-dired-bookmark-jump): New defuns.
---
 etc/NEWS            |  6 ++++++
 lisp/image-dired.el | 35 ++++++++++++++++++++++++++++++++++-
 2 files changed, 40 insertions(+), 1 deletion(-)

diff --git a/etc/NEWS b/etc/NEWS
index 1cb19ee..093c8ac 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -227,6 +227,12 @@ to use it; it is not enabled by default.
 Support for the GraphicsMagick command line tool ("gm") has been
 added, and is used instead of ImageMagick when it is available.
 
+---
+*** Support for bookmark.el.
+The command 'bookmark-set' (bound to 'C-x r m') is now supported in
+the thumbnail view, and will create a bookmark that opens the current
+directory in Image-Dired.
+
 ** Dired
 
 ---
diff --git a/lisp/image-dired.el b/lisp/image-dired.el
index 53cc867..d089d4a 100644
--- a/lisp/image-dired.el
+++ b/lisp/image-dired.el
@@ -1766,7 +1766,8 @@ You probably want to use this together with
   "Browse and manipulate thumbnail images using dired.
 Use `image-dired-minor-mode' to get a nice setup."
   (buffer-disable-undo)
-  (add-hook 'file-name-at-point-functions 'image-dired-file-name-at-point nil 
t))
+  (add-hook 'file-name-at-point-functions 'image-dired-file-name-at-point nil 
t)
+  (setq-local bookmark-make-record-function 
#'image-dired-bookmark-make-record))
 
 (define-derived-mode image-dired-display-image-mode
   special-mode "image-dired-image-display"
@@ -2815,6 +2816,38 @@ tags to their respective image file.  Internal function 
used by
        (dolist (tag tag-list)
          (push (cons file tag) lst))))))
 
+
+;;;; bookmark.el support
+
+(declare-function bookmark-make-record-default
+                  "bookmark" (&optional no-file no-context posn))
+(declare-function bookmark-prop-get "bookmark" (bookmark prop))
+
+(defun image-dired-bookmark-name ()
+  "Create a default bookmark name for the current EWW buffer."
+  (file-name-nondirectory
+   (directory-file-name
+    (file-name-directory (image-dired-original-file-name)))))
+
+(defun image-dired-bookmark-make-record ()
+  "Create a bookmark for the current EWW buffer."
+  `(,(image-dired-bookmark-name)
+    ,@(bookmark-make-record-default t)
+    (location . ,(file-name-directory (image-dired-original-file-name)))
+    (image-dired-file . ,(file-name-nondirectory 
(image-dired-original-file-name)))
+    (handler . image-dired-bookmark-jump)))
+
+;;;###autoload
+(defun image-dired-bookmark-jump (bookmark)
+  "Default bookmark handler for Image-Dired buffers."
+  ;; User already cached thumbnails, so disable any checking.
+  (let ((image-dired-show-all-from-dir-max-files most-positive-fixnum))
+    (image-dired (bookmark-prop-get bookmark 'location))
+    ;; TODO: Go to the bookmarked file, if it exists.
+    ;; (bookmark-prop-get bookmark 'image-dired-file)
+    (goto-char (point-min))))
+
+
 ;;;; Obsolete
 
 ;;;###autoload



reply via email to

[Prev in Thread] Current Thread [Next in Thread]