2016-12-15 19:58:33 -05:00
|
|
|
|
;;; image-dired.el --- use dired to browse and manipulate your images -*- lexical-binding: t -*-
|
2021-10-24 18:36:09 +02:00
|
|
|
|
|
2022-01-01 02:45:51 -05:00
|
|
|
|
;; Copyright (C) 2005-2022 Free Software Foundation, Inc.
|
2021-10-24 18:36:09 +02:00
|
|
|
|
|
2022-08-19 21:14:13 +02:00
|
|
|
|
;; Author: Mathias Dahl <mathias.rem0veth1s.dahl@gmail.com>
|
2022-09-16 17:04:45 +02:00
|
|
|
|
;; Maintainer: Stefan Kangas <stefankangas@gmail.com>
|
2022-09-17 20:43:20 +02:00
|
|
|
|
;; Version: 0.5
|
2007-04-22 13:44:05 +00:00
|
|
|
|
;; Keywords: multimedia
|
|
|
|
|
|
|
|
|
|
;; This file is part of GNU Emacs.
|
|
|
|
|
|
2008-05-06 08:06:51 +00:00
|
|
|
|
;; GNU Emacs is free software: you can redistribute it and/or modify
|
2007-04-22 13:44:05 +00:00
|
|
|
|
;; it under the terms of the GNU General Public License as published by
|
2008-05-06 08:06:51 +00:00
|
|
|
|
;; the Free Software Foundation, either version 3 of the License, or
|
|
|
|
|
;; (at your option) any later version.
|
2007-04-22 13:44:05 +00:00
|
|
|
|
|
|
|
|
|
;; GNU Emacs is distributed in the hope that it will be useful,
|
|
|
|
|
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
;; GNU General Public License for more details.
|
|
|
|
|
|
|
|
|
|
;; You should have received a copy of the GNU General Public License
|
2017-09-13 15:52:52 -07:00
|
|
|
|
;; along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>.
|
2007-04-22 13:44:05 +00:00
|
|
|
|
|
|
|
|
|
;;; Commentary:
|
2021-10-24 18:36:09 +02:00
|
|
|
|
|
2007-04-22 13:44:05 +00:00
|
|
|
|
;; BACKGROUND
|
|
|
|
|
;; ==========
|
|
|
|
|
;;
|
|
|
|
|
;; I needed a program to browse, organize and tag my pictures. I got
|
|
|
|
|
;; tired of the old gallery program I used as it did not allow
|
|
|
|
|
;; multi-file operations easily. Also, it put things out of my
|
|
|
|
|
;; control. Image viewing programs I tested did not allow multi-file
|
|
|
|
|
;; operations or did not do what I wanted it to.
|
|
|
|
|
;;
|
|
|
|
|
;; So, I got the idea to use the wonderful functionality of Emacs and
|
|
|
|
|
;; `dired' to do it. It would allow me to do almost anything I wanted,
|
|
|
|
|
;; which is basically just to browse all my pictures in an easy way,
|
|
|
|
|
;; letting me manipulate and tag them in various ways. `dired' already
|
|
|
|
|
;; provide all the file handling and navigation facilities; I only
|
|
|
|
|
;; needed to add some functions to display the images.
|
|
|
|
|
;;
|
|
|
|
|
;; I briefly tried out thumbs.el, and although it seemed more
|
|
|
|
|
;; powerful than this package, it did not work the way I wanted to. It
|
2021-12-10 02:33:48 +01:00
|
|
|
|
;; was too slow to create thumbnails of all files in a directory (I
|
2007-04-22 13:44:05 +00:00
|
|
|
|
;; currently keep all my 2000+ images in the same directory) and
|
|
|
|
|
;; browsing the thumbnail buffer was slow too. image-dired.el will not
|
|
|
|
|
;; create thumbnails until they are needed and the browsing is done
|
2021-10-27 04:53:41 +02:00
|
|
|
|
;; quickly and easily in Dired. I copied a great deal of ideas and
|
2022-09-18 02:03:16 +02:00
|
|
|
|
;; code from there though... :)
|
2007-04-22 13:44:05 +00:00
|
|
|
|
;;
|
|
|
|
|
;; `image-dired' stores the thumbnail files in `image-dired-dir'
|
|
|
|
|
;; using the file name format ORIGNAME.thumb.ORIGEXT. For example
|
|
|
|
|
;; ~/.emacs.d/image-dired/myimage01.thumb.jpg. The "database" is for
|
|
|
|
|
;; now just a plain text file with the following format:
|
|
|
|
|
;;
|
|
|
|
|
;; file-name-non-directory;comment:comment-text;tag1;tag2;tag3;...;tagN
|
|
|
|
|
;;
|
|
|
|
|
;; PREREQUISITES
|
|
|
|
|
;; =============
|
|
|
|
|
;;
|
2021-10-25 03:50:04 +02:00
|
|
|
|
;; * The GraphicsMagick or ImageMagick package; Image-Dired uses
|
|
|
|
|
;; whichever is available.
|
|
|
|
|
;;
|
|
|
|
|
;; A) For GraphicsMagick, `gm' is used.
|
|
|
|
|
;; Find it here: http://www.graphicsmagick.org/
|
|
|
|
|
;;
|
|
|
|
|
;; B) For ImageMagick, `convert' and `mogrify' are used.
|
|
|
|
|
;; Find it here: https://www.imagemagick.org.
|
2007-04-22 13:44:05 +00:00
|
|
|
|
;;
|
|
|
|
|
;; * For non-lossy rotation of JPEG images, the JpegTRAN program is
|
2021-10-25 03:50:04 +02:00
|
|
|
|
;; needed.
|
2007-04-22 13:44:05 +00:00
|
|
|
|
;;
|
2021-10-23 06:49:09 +02:00
|
|
|
|
;; * For `image-dired-set-exif-data' to work, the command line tool `exiftool' is
|
2021-10-25 03:50:04 +02:00
|
|
|
|
;; needed. It can be found here: https://exiftool.org/. This
|
|
|
|
|
;; function is, among other things, used for writing comments to
|
|
|
|
|
;; image files using `image-dired-thumbnail-set-image-description'.
|
2007-04-22 13:44:05 +00:00
|
|
|
|
;;
|
|
|
|
|
;;
|
|
|
|
|
;; USAGE
|
|
|
|
|
;; =====
|
|
|
|
|
;;
|
|
|
|
|
;; This information has been moved to the manual. Type `C-h r' to open
|
|
|
|
|
;; the Emacs manual and go to the node Thumbnails by typing `g
|
2016-12-13 11:47:21 -05:00
|
|
|
|
;; Image-Dired RET'.
|
2007-04-22 13:44:05 +00:00
|
|
|
|
;;
|
|
|
|
|
;; Quickstart: M-x image-dired RET DIRNAME RET
|
|
|
|
|
;;
|
|
|
|
|
;; where DIRNAME is a directory containing image files.
|
|
|
|
|
;;
|
|
|
|
|
;; LIMITATIONS
|
|
|
|
|
;; ===========
|
|
|
|
|
;;
|
|
|
|
|
;; * Supports all image formats that Emacs and convert supports, but
|
2021-10-24 18:36:09 +02:00
|
|
|
|
;; the thumbnails are hard-coded to JPEG or PNG format. It uses
|
|
|
|
|
;; JPEG by default, but can optionally follow the Thumbnail Managing
|
2021-10-25 02:12:48 +02:00
|
|
|
|
;; Standard (v0.9.0, Dec 2020), which mandates PNG. See the user
|
|
|
|
|
;; option `image-dired-thumbnail-storage'.
|
2007-04-22 13:44:05 +00:00
|
|
|
|
;;
|
|
|
|
|
;; * WARNING: The "database" format used might be changed so keep a
|
2022-09-23 15:01:36 +02:00
|
|
|
|
;; backup of `image-dired-tags-db-file' when testing new versions.
|
2007-04-22 13:44:05 +00:00
|
|
|
|
;;
|
|
|
|
|
;; TODO
|
|
|
|
|
;; ====
|
|
|
|
|
;;
|
|
|
|
|
;; * Investigate if it is possible to also write the tags to the image
|
2021-10-24 18:36:09 +02:00
|
|
|
|
;; files.
|
2007-04-22 13:44:05 +00:00
|
|
|
|
;;
|
|
|
|
|
;; * From thumbs.el: Add an option for clean-up/max-size functionality
|
|
|
|
|
;; for thumbnail directory.
|
|
|
|
|
;;
|
2021-10-24 18:36:09 +02:00
|
|
|
|
;; * Add `image-dired-display-thumbs-ring' and functions to cycle that. Find out
|
|
|
|
|
;; which is best, saving old batch just before inserting new, or
|
|
|
|
|
;; saving the current batch in the ring when inserting it. Adding
|
|
|
|
|
;; it probably needs rewriting `image-dired-display-thumbs' to be more general.
|
2007-04-22 13:44:05 +00:00
|
|
|
|
;;
|
|
|
|
|
;; * Find some way of toggling on and off really nice keybindings in
|
2021-10-27 22:10:04 +02:00
|
|
|
|
;; Dired (for example, using C-n or <down> instead of C-S-n).
|
2021-10-24 18:36:09 +02:00
|
|
|
|
;; Richard suggested that we could keep C-t as prefix for
|
2021-10-27 22:10:04 +02:00
|
|
|
|
;; image-dired commands as it is currently not used in Dired. He
|
2021-10-24 18:36:09 +02:00
|
|
|
|
;; also suggested that `dired-next-line' and `dired-previous-line'
|
|
|
|
|
;; figure out if image-dired is enabled in the current buffer and,
|
|
|
|
|
;; if it is, call `image-dired-dired-next-line' and `image-dired-dired-previous-line',
|
|
|
|
|
;; respectively. Update: This is partly done; some bindings have
|
2021-10-27 22:10:04 +02:00
|
|
|
|
;; now been added to Dired.
|
2007-04-22 13:44:05 +00:00
|
|
|
|
;;
|
|
|
|
|
;; * In some way keep track of buffers and windows and stuff so that
|
2021-10-24 18:36:09 +02:00
|
|
|
|
;; it works as the user expects.
|
2007-04-22 13:44:05 +00:00
|
|
|
|
;;
|
2021-10-24 18:36:09 +02:00
|
|
|
|
;; * More/better documentation.
|
|
|
|
|
|
2007-04-22 13:44:05 +00:00
|
|
|
|
;;; Code:
|
|
|
|
|
|
|
|
|
|
(require 'dired)
|
2016-12-15 13:49:38 -05:00
|
|
|
|
(require 'image-mode)
|
2007-04-22 13:44:05 +00:00
|
|
|
|
(require 'widget)
|
2021-10-25 06:44:30 +02:00
|
|
|
|
(require 'xdg)
|
2007-04-22 13:44:05 +00:00
|
|
|
|
|
|
|
|
|
(eval-when-compile
|
2016-12-03 13:05:39 -05:00
|
|
|
|
(require 'cl-lib)
|
2007-04-22 13:44:05 +00:00
|
|
|
|
(require 'wid-edit))
|
|
|
|
|
|
2022-08-19 21:14:13 +02:00
|
|
|
|
(require 'image-dired-external)
|
|
|
|
|
(require 'image-dired-tags)
|
|
|
|
|
(require 'image-dired-util)
|
|
|
|
|
|
2021-11-08 06:42:44 +01:00
|
|
|
|
|
|
|
|
|
;;; Customizable variables
|
|
|
|
|
|
2007-04-22 13:44:05 +00:00
|
|
|
|
(defgroup image-dired nil
|
2021-10-27 04:53:41 +02:00
|
|
|
|
"Use Dired to browse your images as thumbnails, and more."
|
2007-04-22 13:44:05 +00:00
|
|
|
|
:prefix "image-dired-"
|
2016-12-15 13:25:08 -05:00
|
|
|
|
:link '(info-link "(emacs) Image-Dired")
|
2007-04-22 13:44:05 +00:00
|
|
|
|
:group 'multimedia)
|
|
|
|
|
|
2008-10-24 09:39:27 +00:00
|
|
|
|
(defcustom image-dired-dir (locate-user-emacs-file "image-dired/")
|
2021-10-25 02:12:34 +02:00
|
|
|
|
"Directory where thumbnail images are stored.
|
|
|
|
|
|
2022-09-17 21:06:30 +02:00
|
|
|
|
The value of this option is ignored if Image-Dired is customized
|
|
|
|
|
to use the Thumbnail Managing Standard; they will be saved in
|
|
|
|
|
\"$XDG_CACHE_HOME/thumbnails/\" instead. See
|
2021-10-25 02:12:34 +02:00
|
|
|
|
`image-dired-thumbnail-storage'."
|
2021-08-13 12:28:55 +02:00
|
|
|
|
:type 'directory)
|
2007-04-22 13:44:05 +00:00
|
|
|
|
|
2022-09-17 21:06:30 +02:00
|
|
|
|
(defcustom image-dired-thumbnail-storage 'image-dired
|
2021-10-24 18:36:09 +02:00
|
|
|
|
"How `image-dired' stores thumbnail files.
|
2022-09-17 21:06:30 +02:00
|
|
|
|
There are three ways that Image-Dired can store and generate
|
|
|
|
|
thumbnails:
|
|
|
|
|
|
|
|
|
|
1. According to the \"Thumbnail Managing Standard\", which allows
|
|
|
|
|
sharing of thumbnails across different programs. Thumbnails
|
|
|
|
|
will be stored in \"$XDG_CACHE_HOME/thumbnails/\"
|
|
|
|
|
|
|
|
|
|
Set this user option to one of the following values:
|
|
|
|
|
|
|
|
|
|
- `standard' means use thumbnails sized 128x128.
|
|
|
|
|
- `standard-large' means use thumbnails sized 256x256.
|
|
|
|
|
- `standard-x-large' means use thumbnails sized 512x512.
|
|
|
|
|
- `standard-xx-large' means use thumbnails sized 1024x1024.
|
|
|
|
|
|
|
|
|
|
2. In the Image-Dired specific directory indicated by
|
|
|
|
|
`image-dired-dir'.
|
|
|
|
|
|
|
|
|
|
Set this user option to `image-dired' to use it (or
|
|
|
|
|
`use-image-dired-dir', which means the same thing for
|
|
|
|
|
backwards-compatibility reasons).
|
|
|
|
|
|
|
|
|
|
3. In a subdirectory \".image-dired\" in the same directory
|
|
|
|
|
where the image files are.
|
|
|
|
|
|
|
|
|
|
Set this user option to `per-directory' to use it.
|
|
|
|
|
|
|
|
|
|
To change the default size of thumbnails with (2) and (3) above,
|
|
|
|
|
customize `image-dired-thumb-size'.
|
|
|
|
|
|
|
|
|
|
With Thumbnail Managing Standard, save thumbnails in the PNG
|
|
|
|
|
format, as mandated by that standard, and otherwise as JPEG.
|
2021-10-24 18:36:09 +02:00
|
|
|
|
|
2021-10-25 02:12:48 +02:00
|
|
|
|
For more information on the Thumbnail Managing Standard, see:
|
2021-10-24 18:36:09 +02:00
|
|
|
|
https://specifications.freedesktop.org/thumbnail-spec/thumbnail-spec-latest.html"
|
2007-04-22 13:44:05 +00:00
|
|
|
|
:type '(choice :tag "How to store thumbnail files"
|
2022-09-23 16:08:03 +02:00
|
|
|
|
(const :tag "Use image-dired-dir" image-dired)
|
2021-10-25 02:12:48 +02:00
|
|
|
|
(const :tag "Thumbnail Managing Standard (normal 128x128)"
|
|
|
|
|
standard)
|
|
|
|
|
(const :tag "Thumbnail Managing Standard (large 256x256)"
|
|
|
|
|
standard-large)
|
|
|
|
|
(const :tag "Thumbnail Managing Standard (larger 512x512)"
|
|
|
|
|
standard-x-large)
|
|
|
|
|
(const :tag "Thumbnail Managing Standard (extra large 1024x1024)"
|
|
|
|
|
standard-xx-large)
|
|
|
|
|
(const :tag "Per-directory" per-directory))
|
|
|
|
|
:version "29.1")
|
2022-09-26 15:36:22 +02:00
|
|
|
|
;;;###autoload(put 'image-dired-thumbnail-storage 'safe-local-variable (lambda (x) (eq x 'per-directory)))
|
2021-10-25 02:12:48 +02:00
|
|
|
|
|
2022-09-23 15:01:36 +02:00
|
|
|
|
(define-obsolete-variable-alias 'image-dired-db-file
|
|
|
|
|
'image-dired-tags-db-file "29.1")
|
|
|
|
|
(defcustom image-dired-tags-db-file
|
2010-12-06 14:45:31 -05:00
|
|
|
|
(expand-file-name ".image-dired_db" image-dired-dir)
|
2007-04-22 13:44:05 +00:00
|
|
|
|
"Database file where file names and their associated tags are stored."
|
2021-08-13 12:28:55 +02:00
|
|
|
|
:type 'file)
|
2007-04-22 13:44:05 +00:00
|
|
|
|
|
|
|
|
|
(defcustom image-dired-rotate-original-ask-before-overwrite t
|
|
|
|
|
"Confirm overwrite of original file after rotate operation.
|
|
|
|
|
If non-nil, ask user for confirmation before overwriting the
|
|
|
|
|
original file with `image-dired-temp-rotate-image-file'."
|
2021-08-13 12:28:55 +02:00
|
|
|
|
:type 'boolean)
|
2007-04-22 13:44:05 +00:00
|
|
|
|
|
2022-09-18 01:53:57 +02:00
|
|
|
|
(defcustom image-dired-thumb-size
|
2022-09-17 21:27:38 +02:00
|
|
|
|
;; This is ignored when using the Thumbnail Managing Standard, but
|
|
|
|
|
;; this provides a better default (e.g., when 'image-dired-thumbnail-storage'
|
|
|
|
|
;; is `image-dired' in a directory local variables).
|
|
|
|
|
(pcase image-dired-thumbnail-storage
|
|
|
|
|
('standard 128)
|
|
|
|
|
('standard-large 256)
|
|
|
|
|
('standard-x-large 512)
|
|
|
|
|
('standard-xx-large 1024)
|
2022-09-18 00:21:12 +02:00
|
|
|
|
(_ 128))
|
2022-09-17 21:27:38 +02:00
|
|
|
|
"Default size of thumbnails in pixels.
|
|
|
|
|
The value of this option is ignored if Image-Dired is customized
|
|
|
|
|
to use the Thumbnail Managing Standard; the standard sizes will
|
|
|
|
|
be used instead. See `image-dired-thumbnail-storage'."
|
2022-09-18 00:21:12 +02:00
|
|
|
|
:type 'natnum
|
|
|
|
|
:version "29.1")
|
2007-04-22 13:44:05 +00:00
|
|
|
|
|
|
|
|
|
(defcustom image-dired-thumb-relief 2
|
|
|
|
|
"Size of button-like border around thumbnails."
|
2022-09-17 22:14:31 +02:00
|
|
|
|
:type 'natnum)
|
2007-04-22 13:44:05 +00:00
|
|
|
|
|
|
|
|
|
(defcustom image-dired-thumb-margin 2
|
|
|
|
|
"Size of the margin around thumbnails.
|
|
|
|
|
This is where you see the cursor."
|
2022-09-17 22:14:31 +02:00
|
|
|
|
:type 'natnum)
|
2007-04-22 13:44:05 +00:00
|
|
|
|
|
2021-08-11 14:03:23 +02:00
|
|
|
|
(defcustom image-dired-thumb-visible-marks t
|
2021-11-03 22:34:51 +01:00
|
|
|
|
"Make marks and flags visible in thumbnail buffer.
|
2021-08-11 14:03:23 +02:00
|
|
|
|
If non-nil, apply the `image-dired-thumb-mark' face to marked
|
2021-11-03 22:34:51 +01:00
|
|
|
|
images and `image-dired-thumb-flagged' to images flagged for
|
|
|
|
|
deletion."
|
2021-08-11 14:03:23 +02:00
|
|
|
|
:type 'boolean
|
|
|
|
|
:version "28.1")
|
|
|
|
|
|
2007-04-22 13:44:05 +00:00
|
|
|
|
(defcustom image-dired-line-up-method 'dynamic
|
|
|
|
|
"Default method for line-up of thumbnails in thumbnail buffer.
|
* completion.el (add-completion-to-head, add-completion): Doc fixes.
(completion-search-next, add-completions-from-file):
Fix typos in docstrings.
* filesets.el (filesets-menu-ensure-use-cached)
(filesets-ingroup-patterns, filesets-filetype-property):
* tutorial.el (get-lang-string):
* play/gamegrid.el (gamegrid-score-file-length, gamegrid-add-score):
Fix typos in docstrings.
* image-dired.el (image-dired-dired-after-readin-hook): Doc fix.
(image-dired-line-up-method, image-dired-thumb-size)
(image-dired-cmd-write-exif-data-options, image-dired-write-tags)
(image-dired-track-original-file, image-dired-track-thumbnail)
(image-dired-dired-next-line, image-dired-dired-previous-line)
(image-dired-write-comments): Reflow docstrings.
(image-dired-show-all-from-dir-max-files)
(image-dired-format-properties-string, image-dired-create-thumbs)
(image-dired-mark-tagged-files, image-dired-gallery-generate):
Fix typos in docstrings.
* savehist.el (savehist-save-minibuffer-history, savehist-file)
(savehist-additional-variables, savehist-ignored-variables)
(savehist-file-modes, savehist-autosave-interval):
* startup.el (inhibit-startup-echo-area-message, inhibit-default-init)
(inhibit-startup-buffer-menu, mail-host-address, user-mail-address)
(fancy-splash-image):
* thumbs.el (thumbs-thumbsdir, thumbs-geometry, thumbs-relief)
(thumbs-conversion-program, thumbs-margin):
Remove spurious * in docstrings.
2008-10-25 00:46:25 +00:00
|
|
|
|
Used by `image-dired-display-thumbs' and other functions that needs
|
|
|
|
|
to line-up thumbnails. Dynamic means to use the available width of
|
|
|
|
|
the window containing the thumbnail buffer, Fixed means to use
|
|
|
|
|
`image-dired-thumbs-per-row', Interactive is for asking the user,
|
|
|
|
|
and No line-up means that no automatic line-up will be done."
|
2007-04-22 13:44:05 +00:00
|
|
|
|
:type '(choice :tag "Default line-up method"
|
|
|
|
|
(const :tag "Dynamic" dynamic)
|
2022-08-23 14:59:47 +02:00
|
|
|
|
(const :tag "Fixed" fixed)
|
|
|
|
|
(const :tag "Interactive" interactive)
|
2021-08-13 12:28:55 +02:00
|
|
|
|
(const :tag "No line-up" none)))
|
2007-04-22 13:44:05 +00:00
|
|
|
|
|
|
|
|
|
(defcustom image-dired-thumbs-per-row 3
|
|
|
|
|
"Number of thumbnails to display per row in thumb buffer."
|
2022-09-17 22:14:31 +02:00
|
|
|
|
:type 'natnum)
|
2007-04-22 13:44:05 +00:00
|
|
|
|
|
|
|
|
|
(defcustom image-dired-track-movement t
|
|
|
|
|
"The current state of the tracking and mirroring.
|
|
|
|
|
For more information, see the documentation for
|
|
|
|
|
`image-dired-toggle-movement-tracking'."
|
2021-08-13 12:28:55 +02:00
|
|
|
|
:type 'boolean)
|
2007-04-22 13:44:05 +00:00
|
|
|
|
|
2022-09-24 10:45:37 +02:00
|
|
|
|
(defcustom image-dired-display-properties-format "%n %d/%f %s %t %c"
|
2007-04-22 13:44:05 +00:00
|
|
|
|
"Display format for thumbnail properties.
|
2022-09-15 23:56:11 +02:00
|
|
|
|
This is used for the header line in the Image-Dired buffer.
|
|
|
|
|
|
|
|
|
|
The following %-specs are replaced by `format-spec' before
|
|
|
|
|
displaying:
|
|
|
|
|
|
|
|
|
|
\"%f\" The file name (without a directory) of the
|
|
|
|
|
original image file.
|
2022-09-24 10:45:37 +02:00
|
|
|
|
\"%n\" The number of this image out of the total (e.g. 1/10).
|
|
|
|
|
\"%b\" The associated Dired buffer name.
|
|
|
|
|
\"%d\" The name of the directory that the file is in.
|
|
|
|
|
\"%s\" The image file size.
|
2022-09-15 23:56:11 +02:00
|
|
|
|
\"%t\" The list of tags (from the Image-Dired database).
|
|
|
|
|
\"%c\" The comment (from the Image-Dired database)."
|
|
|
|
|
:type 'string
|
|
|
|
|
:safe #'stringp
|
|
|
|
|
:version "29.1")
|
2007-04-22 13:44:05 +00:00
|
|
|
|
|
|
|
|
|
(defcustom image-dired-external-viewer
|
|
|
|
|
;; TODO: Use mailcap, dired-guess-shell-alist-default,
|
|
|
|
|
;; dired-view-command-alist.
|
2022-09-24 11:06:51 +02:00
|
|
|
|
(cond ((executable-find "display") "display")
|
|
|
|
|
((executable-find "feh") "feh")
|
|
|
|
|
((executable-find "gm") "gm display")
|
|
|
|
|
((executable-find "xli") "xli")
|
2021-10-24 12:20:35 +02:00
|
|
|
|
((executable-find "qiv") "qiv -t")
|
2022-09-24 11:06:51 +02:00
|
|
|
|
((executable-find "xloadimage") "xloadimage"))
|
2007-04-22 13:44:05 +00:00
|
|
|
|
"Name of external viewer.
|
|
|
|
|
Including parameters. Used when displaying original image from
|
|
|
|
|
`image-dired-thumbnail-mode'."
|
2022-09-24 11:06:51 +02:00
|
|
|
|
:version "29.1"
|
2019-10-09 15:28:47 +02:00
|
|
|
|
:type '(choice string
|
2021-08-13 12:28:55 +02:00
|
|
|
|
(const :tag "Not Set" nil)))
|
2007-04-22 13:44:05 +00:00
|
|
|
|
|
2021-10-25 06:44:30 +02:00
|
|
|
|
(defcustom image-dired-main-image-directory
|
|
|
|
|
(or (xdg-user-dir "PICTURES") "~/pics/")
|
2007-04-22 13:44:05 +00:00
|
|
|
|
"Name of main image directory, if any.
|
|
|
|
|
Used by `image-dired-copy-with-exif-file-name'."
|
2021-10-25 06:44:30 +02:00
|
|
|
|
:type 'string
|
|
|
|
|
:version "29.1")
|
2007-04-22 13:44:05 +00:00
|
|
|
|
|
2022-09-03 11:04:07 +02:00
|
|
|
|
(defcustom image-dired-show-all-from-dir-max-files 1000
|
2021-10-25 05:47:56 +02:00
|
|
|
|
"Maximum number of files in directory before prompting.
|
2021-10-27 20:39:10 +02:00
|
|
|
|
|
|
|
|
|
If there are more image files than this in a selected directory,
|
|
|
|
|
the `image-dired-show-all-from-dir' command will ask for
|
|
|
|
|
confirmation before creating the thumbnail buffer. If this
|
|
|
|
|
variable is nil, it will never ask."
|
|
|
|
|
:type '(choice integer
|
|
|
|
|
(const :tag "Disable warning" nil))
|
2021-10-25 05:47:56 +02:00
|
|
|
|
:version "29.1")
|
2007-04-22 13:44:05 +00:00
|
|
|
|
|
2021-12-09 00:57:34 +01:00
|
|
|
|
(defcustom image-dired-marking-shows-next t
|
|
|
|
|
"If non-nil, marking, unmarking or flagging an image shows the next image.
|
|
|
|
|
|
|
|
|
|
This affects the following commands:
|
|
|
|
|
\\<image-dired-thumbnail-mode-map>
|
|
|
|
|
`image-dired-flag-thumb-original-file' (bound to \\[image-dired-flag-thumb-original-file])
|
|
|
|
|
`image-dired-mark-thumb-original-file' (bound to \\[image-dired-mark-thumb-original-file])
|
|
|
|
|
`image-dired-unmark-thumb-original-file' (bound to \\[image-dired-unmark-thumb-original-file])"
|
|
|
|
|
:type 'boolean
|
|
|
|
|
:version "29.1")
|
|
|
|
|
|
2022-09-24 20:08:25 +02:00
|
|
|
|
|
|
|
|
|
;;; Faces
|
|
|
|
|
|
|
|
|
|
;;;; Header line
|
|
|
|
|
|
|
|
|
|
(defface image-dired-thumb-header-file-name
|
|
|
|
|
'((default :weight bold))
|
|
|
|
|
"Face for the file name in the header line of the thumbnail buffer."
|
|
|
|
|
:version "29.1")
|
|
|
|
|
|
|
|
|
|
(defface image-dired-thumb-header-directory-name
|
|
|
|
|
'((default :inherit header-line))
|
|
|
|
|
"Face for the directory name in the header line of the thumbnail buffer."
|
|
|
|
|
:version "29.1")
|
|
|
|
|
|
2022-09-27 23:28:26 +02:00
|
|
|
|
(defface image-dired-thumb-header-file-size
|
2022-09-24 20:08:25 +02:00
|
|
|
|
'((((class color) (min-colors 88)) :foreground "cadet blue")
|
|
|
|
|
(((class color) (min-colors 16)) :foreground "black")
|
|
|
|
|
(default :inherit header-line))
|
|
|
|
|
"Face for the file size in the header line of the thumbnail buffer."
|
|
|
|
|
:version "29.1")
|
|
|
|
|
|
|
|
|
|
(defface image-dired-thumb-header-image-count
|
|
|
|
|
'((default :inherit header-line))
|
|
|
|
|
"Face for the image count in the header line of the thumbnail buffer."
|
|
|
|
|
:version "29.1")
|
|
|
|
|
|
|
|
|
|
;;;; Thumbnail buffer
|
|
|
|
|
|
|
|
|
|
(defface image-dired-thumb-mark
|
|
|
|
|
'((((class color) (min-colors 16)) :background "DarkOrange")
|
|
|
|
|
(((class color)) :foreground "yellow")
|
|
|
|
|
(default :inherit header-line))
|
|
|
|
|
"Face for marked images in thumbnail buffer."
|
|
|
|
|
:version "29.1")
|
|
|
|
|
|
|
|
|
|
(defface image-dired-thumb-flagged
|
|
|
|
|
'((((class color) (min-colors 88) (background light)) :background "Red3")
|
|
|
|
|
(((class color) (min-colors 88) (background dark)) :background "Pink")
|
|
|
|
|
(((class color) (min-colors 16) (background light)) :background "Red3")
|
|
|
|
|
(((class color) (min-colors 16) (background dark)) :background "Pink")
|
|
|
|
|
(((class color) (min-colors 8)) :background "red")
|
|
|
|
|
(t :inverse-video t))
|
|
|
|
|
"Face for images flagged for deletion in thumbnail buffer."
|
|
|
|
|
:version "29.1")
|
|
|
|
|
|
2021-11-08 06:42:44 +01:00
|
|
|
|
|
|
|
|
|
;;; Util functions
|
|
|
|
|
|
2022-09-16 21:54:29 +02:00
|
|
|
|
(defun image-dired--file-name-regexp ()
|
|
|
|
|
(let ((image-file-name-extensions
|
|
|
|
|
(append '("pdf") image-file-name-extensions)))
|
|
|
|
|
(image-file-name-regexp)))
|
|
|
|
|
|
2007-04-22 13:44:05 +00:00
|
|
|
|
(defun image-dired-insert-image (file type relief margin)
|
|
|
|
|
"Insert image FILE of image TYPE, using RELIEF and MARGIN, at point."
|
|
|
|
|
(let ((i `(image :type ,type
|
|
|
|
|
:file ,file
|
|
|
|
|
:relief ,relief
|
|
|
|
|
:margin ,margin)))
|
|
|
|
|
(insert-image i)))
|
|
|
|
|
|
2022-09-24 13:08:11 +02:00
|
|
|
|
(defun image-dired--get-create-thumbnail-file (file)
|
2007-04-22 13:44:05 +00:00
|
|
|
|
"Return the image descriptor for a thumbnail of image file FILE."
|
2022-09-16 21:54:29 +02:00
|
|
|
|
(unless (string-match-p (image-dired--file-name-regexp) file)
|
2007-04-22 13:44:05 +00:00
|
|
|
|
(error "%s is not a valid image file" file))
|
2017-10-22 01:04:36 -07:00
|
|
|
|
(let* ((thumb-file (image-dired-thumb-name file))
|
2022-08-23 14:59:47 +02:00
|
|
|
|
(thumb-attr (file-attributes thumb-file)))
|
2022-09-24 13:08:11 +02:00
|
|
|
|
(if (or (not thumb-attr)
|
|
|
|
|
(time-less-p (file-attribute-modification-time thumb-attr)
|
|
|
|
|
(file-attribute-modification-time
|
|
|
|
|
(file-attributes file))))
|
|
|
|
|
(image-dired-create-thumb file thumb-file)
|
|
|
|
|
(image-dired-debug "Found thumb for %s: %s"
|
|
|
|
|
(file-name-nondirectory file)
|
|
|
|
|
(file-name-nondirectory thumb-file)))
|
|
|
|
|
thumb-file))
|
2007-04-22 13:44:05 +00:00
|
|
|
|
|
2022-08-23 14:59:47 +02:00
|
|
|
|
(defun image-dired-insert-thumbnail ( file original-file-name
|
2022-09-24 10:45:37 +02:00
|
|
|
|
associated-dired-buffer image-number)
|
2007-04-22 13:44:05 +00:00
|
|
|
|
"Insert thumbnail image FILE.
|
2022-09-24 10:45:37 +02:00
|
|
|
|
Add text properties ORIGINAL-FILE-NAME, ASSOCIATED-DIRED-BUFFER
|
|
|
|
|
and IMAGE-NUMBER."
|
2007-04-22 13:44:05 +00:00
|
|
|
|
(let (beg end)
|
|
|
|
|
(setq beg (point))
|
2021-10-24 18:18:43 +02:00
|
|
|
|
(image-dired-insert-image
|
|
|
|
|
file
|
|
|
|
|
;; Thumbnails are created asynchronously, so we might not yet
|
|
|
|
|
;; have a file. But if it exists, it might have been cached from
|
|
|
|
|
;; before and we should use it instead of our current settings.
|
|
|
|
|
(or (and (file-exists-p file)
|
|
|
|
|
(image-type-from-file-header file))
|
|
|
|
|
(and (memq image-dired-thumbnail-storage
|
2021-10-25 02:12:48 +02:00
|
|
|
|
image-dired--thumbnail-standard-sizes)
|
2021-10-24 18:18:43 +02:00
|
|
|
|
'png)
|
|
|
|
|
'jpeg)
|
|
|
|
|
image-dired-thumb-relief
|
|
|
|
|
image-dired-thumb-margin)
|
2007-04-22 13:44:05 +00:00
|
|
|
|
(setq end (point))
|
|
|
|
|
(add-text-properties
|
|
|
|
|
beg end
|
|
|
|
|
(list 'image-dired-thumbnail t
|
2022-09-23 17:22:47 +02:00
|
|
|
|
;; Disable `image-map' on thumbnails.
|
|
|
|
|
'keymap nil
|
2007-04-22 13:44:05 +00:00
|
|
|
|
'original-file-name original-file-name
|
|
|
|
|
'associated-dired-buffer associated-dired-buffer
|
2022-09-24 10:45:37 +02:00
|
|
|
|
'image-number image-number
|
2007-04-22 13:44:05 +00:00
|
|
|
|
'tags (image-dired-list-tags original-file-name)
|
|
|
|
|
'mouse-face 'highlight
|
|
|
|
|
'comment (image-dired-get-comment original-file-name)))))
|
|
|
|
|
|
2021-08-18 14:53:25 +02:00
|
|
|
|
(defmacro image-dired--with-marked (&rest body)
|
|
|
|
|
"Eval BODY with point on each marked thumbnail.
|
|
|
|
|
If no marked file could be found, execute BODY on the current
|
2022-09-29 01:25:10 +02:00
|
|
|
|
thumbnail. It's expected that a thumbnail is always followed
|
|
|
|
|
by exactly one space or one newline character."
|
2021-08-18 14:53:25 +02:00
|
|
|
|
`(with-current-buffer image-dired-thumbnail-buffer
|
|
|
|
|
(let (found)
|
|
|
|
|
(save-mark-and-excursion
|
|
|
|
|
(goto-char (point-min))
|
|
|
|
|
(while (not (eobp))
|
|
|
|
|
(when (image-dired-thumb-file-marked-p)
|
|
|
|
|
(setq found t)
|
|
|
|
|
,@body)
|
2022-09-27 02:14:54 +02:00
|
|
|
|
(forward-char 2)))
|
2021-08-18 14:53:25 +02:00
|
|
|
|
(unless found
|
|
|
|
|
,@body))))
|
|
|
|
|
|
2007-04-22 13:44:05 +00:00
|
|
|
|
(defun image-dired-create-thumbnail-buffer ()
|
|
|
|
|
"Create thumb buffer and set `image-dired-thumbnail-mode'."
|
|
|
|
|
(let ((buf (get-buffer-create image-dired-thumbnail-buffer)))
|
|
|
|
|
(with-current-buffer buf
|
|
|
|
|
(setq buffer-read-only t)
|
|
|
|
|
(if (not (eq major-mode 'image-dired-thumbnail-mode))
|
|
|
|
|
(image-dired-thumbnail-mode)))
|
|
|
|
|
buf))
|
|
|
|
|
|
|
|
|
|
(defvar image-dired-saved-window-configuration nil
|
|
|
|
|
"Saved window configuration.")
|
|
|
|
|
|
2022-09-24 11:10:29 +02:00
|
|
|
|
|
|
|
|
|
;;; Starting Image-Dired
|
|
|
|
|
|
2007-04-22 13:44:05 +00:00
|
|
|
|
;;;###autoload
|
|
|
|
|
(defun image-dired-dired-with-window-configuration (dir &optional arg)
|
|
|
|
|
"Open directory DIR and create a default window configuration.
|
|
|
|
|
|
|
|
|
|
Convenience command that:
|
|
|
|
|
|
2021-10-27 04:53:41 +02:00
|
|
|
|
- Opens Dired in folder DIR
|
2007-04-22 13:44:05 +00:00
|
|
|
|
- Splits windows in most useful (?) way
|
2021-10-27 04:53:41 +02:00
|
|
|
|
- Sets `truncate-lines' to t
|
2007-04-22 13:44:05 +00:00
|
|
|
|
|
|
|
|
|
After the command has finished, you would typically mark some
|
2021-10-27 04:53:41 +02:00
|
|
|
|
image files in Dired and type
|
2007-04-22 13:44:05 +00:00
|
|
|
|
\\[image-dired-display-thumbs] (`image-dired-display-thumbs').
|
|
|
|
|
|
|
|
|
|
If called with prefix argument ARG, skip splitting of windows.
|
|
|
|
|
|
|
|
|
|
The current window configuration is saved and can be restored by
|
|
|
|
|
calling `image-dired-restore-window-configuration'."
|
|
|
|
|
(interactive "DDirectory: \nP")
|
|
|
|
|
(let ((buf (image-dired-create-thumbnail-buffer))
|
2021-11-04 02:05:29 +01:00
|
|
|
|
(buf2 (get-buffer-create image-dired-display-image-buffer)))
|
2007-04-22 13:44:05 +00:00
|
|
|
|
(setq image-dired-saved-window-configuration
|
|
|
|
|
(current-window-configuration))
|
|
|
|
|
(dired dir)
|
|
|
|
|
(delete-other-windows)
|
|
|
|
|
(when (not arg)
|
2011-10-30 09:56:03 +08:00
|
|
|
|
(split-window-right)
|
2007-04-22 13:44:05 +00:00
|
|
|
|
(setq truncate-lines t)
|
|
|
|
|
(save-excursion
|
|
|
|
|
(other-window 1)
|
2016-12-02 16:50:25 -05:00
|
|
|
|
(pop-to-buffer-same-window buf)
|
2011-10-30 09:56:03 +08:00
|
|
|
|
(select-window (split-window-below))
|
2016-12-02 16:50:25 -05:00
|
|
|
|
(pop-to-buffer-same-window buf2)
|
2007-04-22 13:44:05 +00:00
|
|
|
|
(other-window -2)))))
|
|
|
|
|
|
|
|
|
|
(defun image-dired-restore-window-configuration ()
|
|
|
|
|
"Restore window configuration.
|
|
|
|
|
Restore any changes to the window configuration made by calling
|
|
|
|
|
`image-dired-dired-with-window-configuration'."
|
2021-10-28 02:10:09 +02:00
|
|
|
|
(interactive nil image-dired-thumbnail-mode)
|
2007-04-22 13:44:05 +00:00
|
|
|
|
(if image-dired-saved-window-configuration
|
|
|
|
|
(set-window-configuration image-dired-saved-window-configuration)
|
|
|
|
|
(message "No saved window configuration")))
|
|
|
|
|
|
2021-08-11 18:02:25 +02:00
|
|
|
|
(defun image-dired--line-up-with-method ()
|
|
|
|
|
"Line up thumbnails according to `image-dired-line-up-method'."
|
|
|
|
|
(cond ((eq 'dynamic image-dired-line-up-method)
|
|
|
|
|
(image-dired-line-up-dynamic))
|
|
|
|
|
((eq 'fixed image-dired-line-up-method)
|
|
|
|
|
(image-dired-line-up))
|
|
|
|
|
((eq 'interactive image-dired-line-up-method)
|
|
|
|
|
(image-dired-line-up-interactive))
|
|
|
|
|
((eq 'none image-dired-line-up-method)
|
|
|
|
|
nil)
|
|
|
|
|
(t
|
|
|
|
|
(image-dired-line-up-dynamic))))
|
|
|
|
|
|
2022-09-24 10:45:37 +02:00
|
|
|
|
(defvar-local image-dired--number-of-thumbnails nil)
|
|
|
|
|
|
2007-04-22 13:44:05 +00:00
|
|
|
|
;;;###autoload
|
|
|
|
|
(defun image-dired-display-thumbs (&optional arg append do-not-pop)
|
|
|
|
|
"Display thumbnails of all marked files, in `image-dired-thumbnail-buffer'.
|
|
|
|
|
If a thumbnail image does not exist for a file, it is created on the
|
|
|
|
|
fly. With prefix argument ARG, display only thumbnail for file at
|
|
|
|
|
point (this is useful if you have marked some files but want to show
|
|
|
|
|
another one).
|
|
|
|
|
|
|
|
|
|
Recommended usage is to split the current frame horizontally so that
|
2021-10-27 04:53:41 +02:00
|
|
|
|
you have the Dired buffer in the left window and the
|
2007-04-22 13:44:05 +00:00
|
|
|
|
`image-dired-thumbnail-buffer' buffer in the right window.
|
|
|
|
|
|
|
|
|
|
With optional argument APPEND, append thumbnail to thumbnail buffer
|
|
|
|
|
instead of erasing it first.
|
|
|
|
|
|
Fix typos in docstrings.
* image-dired.el (image-dired-display-thumbs): Fix typo in docstring.
(image-dired-read-comment): Doc fix.
* json.el (json-object-type, json-array-type, json-key-type, json-false)
(json-null, json-read-number):
* minibuffer.el (completion-in-region-functions):
* calendar/cal-tex.el (cal-tex-daily-end, cal-tex-number-weeks)
(cal-tex-cursor-week):
* emacs-lisp/trace.el (trace-function):
* eshell/em-basic.el (eshell/printnl):
* eshell/em-dirs.el (eshell-last-dir-ring, eshell-parse-drive-letter)
(eshell-read-last-dir-ring, eshell-write-last-dir-ring):
* obsolete/levents.el (allocate-event, event-key, event-object)
(event-point, event-process, event-timestamp, event-to-character)
(event-window, event-x, event-x-pixel, event-y, event-y-pixel):
* textmodes/reftex-vars.el (reftex-index-macros-builtin)
(reftex-section-levels, reftex-auto-recenter-toc, reftex-toc-mode-hook)
(reftex-cite-punctuation, reftex-search-unrecursed-path-first)
(reftex-highlight-selection): Fix typos in docstrings.
2010-03-22 17:50:29 +01:00
|
|
|
|
Optional argument DO-NOT-POP controls if `pop-to-buffer' should be
|
2007-04-22 13:44:05 +00:00
|
|
|
|
used or not. If non-nil, use `display-buffer' instead of
|
|
|
|
|
`pop-to-buffer'. This is used from functions like
|
|
|
|
|
`image-dired-next-line-and-display' and
|
|
|
|
|
`image-dired-previous-line-and-display' where we do not want the
|
|
|
|
|
thumbnail buffer to be selected."
|
2022-08-20 22:44:14 +02:00
|
|
|
|
(interactive "P" nil dired-mode)
|
2021-10-27 01:32:58 +02:00
|
|
|
|
(setq image-dired--generate-thumbs-start (current-time))
|
2007-04-22 13:44:05 +00:00
|
|
|
|
(let ((buf (image-dired-create-thumbnail-buffer))
|
2022-09-24 13:08:11 +02:00
|
|
|
|
files dired-buf)
|
2007-04-22 13:44:05 +00:00
|
|
|
|
(if arg
|
|
|
|
|
(setq files (list (dired-get-filename)))
|
|
|
|
|
(setq files (dired-get-marked-files)))
|
|
|
|
|
(setq dired-buf (current-buffer))
|
|
|
|
|
(with-current-buffer buf
|
|
|
|
|
(let ((inhibit-read-only t))
|
|
|
|
|
(if (not append)
|
2022-09-24 10:45:37 +02:00
|
|
|
|
(progn
|
|
|
|
|
(setq image-dired--number-of-thumbnails 0)
|
|
|
|
|
(erase-buffer))
|
2007-04-22 13:44:05 +00:00
|
|
|
|
(goto-char (point-max)))
|
2022-09-24 13:08:11 +02:00
|
|
|
|
(dolist (file files)
|
|
|
|
|
(let ((thumb (image-dired--get-create-thumbnail-file file)))
|
2022-09-24 10:45:37 +02:00
|
|
|
|
(image-dired-insert-thumbnail
|
|
|
|
|
thumb file dired-buf
|
|
|
|
|
(cl-incf image-dired--number-of-thumbnails)))))
|
2016-12-02 16:53:02 -05:00
|
|
|
|
(if do-not-pop
|
|
|
|
|
(display-buffer buf)
|
|
|
|
|
(pop-to-buffer buf))
|
2021-08-11 18:02:25 +02:00
|
|
|
|
(image-dired--line-up-with-method))))
|
2007-04-22 13:44:05 +00:00
|
|
|
|
|
|
|
|
|
;;;###autoload
|
|
|
|
|
(defun image-dired-show-all-from-dir (dir)
|
2021-10-27 20:39:10 +02:00
|
|
|
|
"Make a thumbnail buffer for all images in DIR and display it.
|
2022-09-16 21:54:29 +02:00
|
|
|
|
Any file matching `image-dired--file-name-regexp' is considered an
|
|
|
|
|
image file.
|
2021-10-27 20:39:10 +02:00
|
|
|
|
|
|
|
|
|
If the number of image files in DIR exceeds
|
|
|
|
|
`image-dired-show-all-from-dir-max-files', ask for confirmation
|
|
|
|
|
before creating the thumbnail buffer. If that variable is nil,
|
|
|
|
|
never ask for confirmation."
|
2022-09-24 11:07:45 +02:00
|
|
|
|
(interactive "DShow thumbnails for directory: ")
|
2007-04-22 13:44:05 +00:00
|
|
|
|
(dired dir)
|
2022-09-16 21:54:29 +02:00
|
|
|
|
(dired-mark-files-regexp (image-dired--file-name-regexp))
|
2021-10-27 21:04:10 +02:00
|
|
|
|
(let ((files (dired-get-marked-files nil nil nil t)))
|
|
|
|
|
(cond ((and (null (cdr files)))
|
|
|
|
|
(message "No image files in directory"))
|
|
|
|
|
((or (not image-dired-show-all-from-dir-max-files)
|
|
|
|
|
(<= (length (cdr files)) image-dired-show-all-from-dir-max-files)
|
|
|
|
|
(and (> (length (cdr files)) image-dired-show-all-from-dir-max-files)
|
|
|
|
|
(y-or-n-p
|
|
|
|
|
(format
|
|
|
|
|
"Directory contains more than %d image files. Proceed?"
|
|
|
|
|
image-dired-show-all-from-dir-max-files))))
|
|
|
|
|
(image-dired-display-thumbs)
|
2022-09-24 11:49:46 +02:00
|
|
|
|
(let ((inhibit-message t))
|
|
|
|
|
(dired-unmark-all-marks))
|
2021-11-03 07:14:21 +01:00
|
|
|
|
(pop-to-buffer image-dired-thumbnail-buffer)
|
2021-11-04 05:10:28 +01:00
|
|
|
|
(setq default-directory dir)
|
2022-09-24 10:45:37 +02:00
|
|
|
|
(image-dired--update-header-line))
|
2021-10-27 21:04:10 +02:00
|
|
|
|
(t (message "Image-Dired canceled")))))
|
2007-04-22 13:44:05 +00:00
|
|
|
|
|
|
|
|
|
;;;###autoload
|
|
|
|
|
(defalias 'image-dired 'image-dired-show-all-from-dir)
|
|
|
|
|
|
2021-11-08 06:42:44 +01:00
|
|
|
|
|
2022-09-24 11:10:29 +02:00
|
|
|
|
;;; Movement tracking
|
2021-11-08 06:42:44 +01:00
|
|
|
|
|
2007-04-22 13:44:05 +00:00
|
|
|
|
(defun image-dired-track-original-file ()
|
2021-10-27 04:53:41 +02:00
|
|
|
|
"Track the original file in the associated Dired buffer.
|
2022-09-24 11:49:46 +02:00
|
|
|
|
See `image-dired-toggle-movement-tracking'. Interactive use is
|
|
|
|
|
only useful if `image-dired-track-movement' is nil."
|
2022-10-04 17:36:09 +02:00
|
|
|
|
(interactive nil image-dired-thumbnail-mode image-dired-image-mode)
|
2022-09-24 11:49:46 +02:00
|
|
|
|
(let ((file-name (image-dired-original-file-name)))
|
|
|
|
|
(image-dired--with-dired-buffer
|
|
|
|
|
(if (not (dired-goto-file file-name))
|
|
|
|
|
(message "Could not find image in Dired buffer for tracking")
|
|
|
|
|
(when-let (window (image-dired-get-buffer-window (current-buffer)))
|
|
|
|
|
(set-window-point window (point)))))))
|
2007-04-22 13:44:05 +00:00
|
|
|
|
|
|
|
|
|
(defun image-dired-toggle-movement-tracking ()
|
|
|
|
|
"Turn on and off `image-dired-track-movement'.
|
2021-10-27 04:53:41 +02:00
|
|
|
|
Tracking of the movements between thumbnail and Dired buffer so that
|
2007-04-22 13:44:05 +00:00
|
|
|
|
they are \"mirrored\" in the dired buffer. When this is on, moving
|
|
|
|
|
around in the thumbnail or dired buffer will find the matching
|
|
|
|
|
position in the other buffer."
|
2022-10-04 17:36:09 +02:00
|
|
|
|
(interactive nil image-dired-thumbnail-mode image-dired-image-mode)
|
2007-04-22 13:44:05 +00:00
|
|
|
|
(setq image-dired-track-movement (not image-dired-track-movement))
|
2021-11-03 03:00:23 +01:00
|
|
|
|
(message "Movement tracking %s" (if image-dired-track-movement "on" "off")))
|
2007-04-22 13:44:05 +00:00
|
|
|
|
|
2022-09-24 11:10:29 +02:00
|
|
|
|
|
|
|
|
|
;;; Navigation
|
2021-10-27 03:43:21 +02:00
|
|
|
|
|
2021-11-03 03:34:28 +01:00
|
|
|
|
(defun image-dired-forward-image (&optional arg wrap-around)
|
2022-09-23 23:47:23 +02:00
|
|
|
|
"Move to next image in the thumbnail buffer.
|
2021-11-03 03:34:28 +01:00
|
|
|
|
Optional prefix ARG says how many images to move; the default is
|
|
|
|
|
one image. Negative means move backwards.
|
|
|
|
|
On reaching end or beginning of buffer, stop and show a message.
|
|
|
|
|
|
|
|
|
|
If optional argument WRAP-AROUND is non-nil, wrap around: if
|
|
|
|
|
point is on the last image, move to the last one and vice versa."
|
2022-08-20 22:44:14 +02:00
|
|
|
|
(interactive "p" image-dired-thumbnail-mode)
|
2021-11-03 03:34:28 +01:00
|
|
|
|
(setq arg (or arg 1))
|
|
|
|
|
(let (pos)
|
|
|
|
|
(dotimes (_ (abs arg))
|
|
|
|
|
(if (and (not (if (> arg 0) (eobp) (bobp)))
|
2007-04-22 13:44:05 +00:00
|
|
|
|
(save-excursion
|
2021-11-03 03:34:28 +01:00
|
|
|
|
(forward-char (if (> arg 0) 1 -1))
|
|
|
|
|
(while (and (not (if (> arg 0) (eobp) (bobp)))
|
2007-04-22 13:44:05 +00:00
|
|
|
|
(not (image-dired-image-at-point-p)))
|
2021-11-03 03:34:28 +01:00
|
|
|
|
(forward-char (if (> arg 0) 1 -1)))
|
2007-04-22 13:44:05 +00:00
|
|
|
|
(setq pos (point))
|
|
|
|
|
(image-dired-image-at-point-p)))
|
2022-09-24 20:18:48 +02:00
|
|
|
|
(goto-char pos)
|
2021-11-03 03:34:28 +01:00
|
|
|
|
(if wrap-around
|
2022-09-24 20:18:48 +02:00
|
|
|
|
(goto-char (if (> arg 0)
|
|
|
|
|
(point-min)
|
|
|
|
|
;; There are two spaces after the last image.
|
|
|
|
|
(- (point-max) 2)))
|
|
|
|
|
(message "At %s image" (if (> arg 0) "last" "first"))))))
|
|
|
|
|
(image-dired--update-header-line)
|
2007-04-22 13:44:05 +00:00
|
|
|
|
(when image-dired-track-movement
|
2021-10-27 03:43:21 +02:00
|
|
|
|
(image-dired-track-original-file)))
|
2007-04-22 13:44:05 +00:00
|
|
|
|
|
|
|
|
|
(defun image-dired-backward-image (&optional arg)
|
2022-09-23 23:47:23 +02:00
|
|
|
|
"Move to previous image in the thumbnail buffer.
|
2021-11-03 03:34:28 +01:00
|
|
|
|
Optional prefix ARG says how many images to move; the default is
|
|
|
|
|
one image. Negative means move forward.
|
|
|
|
|
On reaching end or beginning of buffer, stop and show a message."
|
2022-08-20 22:44:14 +02:00
|
|
|
|
(interactive "p" image-dired-thumbnail-mode)
|
2021-11-03 03:34:28 +01:00
|
|
|
|
(image-dired-forward-image (- (or arg 1))))
|
2007-04-22 13:44:05 +00:00
|
|
|
|
|
2022-09-24 13:36:39 +02:00
|
|
|
|
(defun image-dired--movement-ensure-point-pos (&optional reverse)
|
|
|
|
|
"Ensure point is on an image."
|
|
|
|
|
(while (and (not (image-at-point-p))
|
|
|
|
|
(not (if reverse (bobp) (eobp))))
|
|
|
|
|
(forward-char (if reverse -1 1))))
|
|
|
|
|
|
|
|
|
|
(defmacro image-dired--movement-command (to &optional reverse)
|
|
|
|
|
`(progn
|
|
|
|
|
(goto-char ,to)
|
|
|
|
|
(image-dired--movement-ensure-point-pos ,reverse)
|
|
|
|
|
(when image-dired-track-movement
|
|
|
|
|
(image-dired-track-original-file))
|
2022-09-24 10:45:37 +02:00
|
|
|
|
(image-dired--update-header-line)))
|
2022-09-24 13:36:39 +02:00
|
|
|
|
|
|
|
|
|
(defmacro image-dired--movement-command-line (&optional reverse)
|
|
|
|
|
`(image-dired--movement-command
|
|
|
|
|
(let ((goal-column (current-column)))
|
|
|
|
|
(forward-line ,(if reverse -1 1))
|
|
|
|
|
(move-to-column goal-column)
|
|
|
|
|
(point))
|
|
|
|
|
,reverse))
|
|
|
|
|
|
2007-04-22 13:44:05 +00:00
|
|
|
|
(defun image-dired-next-line ()
|
2022-09-23 23:47:23 +02:00
|
|
|
|
"Move to next line in the thumbnail buffer."
|
2021-10-28 02:10:09 +02:00
|
|
|
|
(interactive nil image-dired-thumbnail-mode)
|
2022-09-24 13:36:39 +02:00
|
|
|
|
(image-dired--movement-command-line))
|
2007-04-22 13:44:05 +00:00
|
|
|
|
|
|
|
|
|
(defun image-dired-previous-line ()
|
2022-09-23 23:47:23 +02:00
|
|
|
|
"Move to previous line in the thumbnail buffer."
|
2021-10-28 02:10:09 +02:00
|
|
|
|
(interactive nil image-dired-thumbnail-mode)
|
2022-09-24 13:36:39 +02:00
|
|
|
|
(image-dired--movement-command-line 'reverse))
|
2007-04-22 13:44:05 +00:00
|
|
|
|
|
2021-10-27 03:23:49 +02:00
|
|
|
|
(defun image-dired-beginning-of-buffer ()
|
2022-09-23 23:47:23 +02:00
|
|
|
|
"Move to the first image in the thumbnail buffer."
|
2021-10-27 03:23:49 +02:00
|
|
|
|
(interactive nil image-dired-thumbnail-mode)
|
2022-09-24 13:36:39 +02:00
|
|
|
|
(image-dired--movement-command (point-min)))
|
2021-10-27 03:23:49 +02:00
|
|
|
|
|
|
|
|
|
(defun image-dired-end-of-buffer ()
|
2022-09-23 23:47:23 +02:00
|
|
|
|
"Move to the last image in the thumbnail buffer."
|
2021-10-27 03:23:49 +02:00
|
|
|
|
(interactive nil image-dired-thumbnail-mode)
|
2022-09-24 13:36:39 +02:00
|
|
|
|
(image-dired--movement-command (point-max) 'reverse))
|
|
|
|
|
|
|
|
|
|
(defun image-dired-move-beginning-of-line ()
|
|
|
|
|
"Move to the beginning of current line in thumbnail buffer."
|
|
|
|
|
(interactive nil image-dired-thumbnail-mode)
|
|
|
|
|
(image-dired--movement-command (pos-bol)))
|
|
|
|
|
|
|
|
|
|
(defun image-dired-move-end-of-line ()
|
|
|
|
|
"Move to the end of current line in thumbnail buffer."
|
|
|
|
|
(interactive nil image-dired-thumbnail-mode)
|
|
|
|
|
(image-dired--movement-command (pos-eol) 'reverse))
|
2021-10-27 03:23:49 +02:00
|
|
|
|
|
2022-09-24 11:10:29 +02:00
|
|
|
|
|
|
|
|
|
;;; Header line
|
|
|
|
|
|
2022-09-24 10:45:37 +02:00
|
|
|
|
(defun image-dired-format-properties-string (buf file image-count props comment)
|
2007-04-22 13:44:05 +00:00
|
|
|
|
"Format display properties.
|
2022-09-24 10:45:37 +02:00
|
|
|
|
BUF is the associated Dired buffer, FILE is the original image
|
|
|
|
|
file name, IMAGE-COUNT is a string like \"N/M\" where N is the
|
|
|
|
|
number of this image and M is the total number of images, PROPS
|
|
|
|
|
is a stringified list of tags, and COMMENT is the image file's
|
2007-04-22 13:44:05 +00:00
|
|
|
|
comment."
|
|
|
|
|
(format-spec
|
|
|
|
|
image-dired-display-properties-format
|
2022-09-24 10:45:37 +02:00
|
|
|
|
`((?b . ,(or buf ""))
|
2022-09-24 20:08:25 +02:00
|
|
|
|
(?d . ,(propertize
|
|
|
|
|
(file-name-nondirectory
|
|
|
|
|
(directory-file-name
|
|
|
|
|
(file-name-directory file)))
|
|
|
|
|
'face 'image-dired-thumb-header-directory-name))
|
|
|
|
|
(?f . ,(propertize (file-name-nondirectory file)
|
|
|
|
|
'face 'image-dired-thumb-header-file-name))
|
|
|
|
|
(?n . ,(propertize image-count
|
|
|
|
|
'face 'image-dired-thumb-header-image-count))
|
2022-09-27 22:58:31 +02:00
|
|
|
|
(?s . ,(propertize (if (file-exists-p file)
|
|
|
|
|
(file-size-human-readable
|
|
|
|
|
(file-attribute-size
|
|
|
|
|
(file-attributes file)))
|
|
|
|
|
"<File missing>")
|
2022-09-24 20:08:25 +02:00
|
|
|
|
'face 'image-dired-thumb-header-file-size))
|
2022-09-24 10:45:37 +02:00
|
|
|
|
(?t . ,(or props ""))
|
|
|
|
|
(?c . ,(or comment "")))))
|
|
|
|
|
|
|
|
|
|
(defun image-dired--update-header-line ()
|
2021-12-09 03:28:19 +01:00
|
|
|
|
"Update image information in the header line."
|
2022-09-24 10:45:37 +02:00
|
|
|
|
(when (derived-mode-p 'image-dired-thumbnail-mode)
|
|
|
|
|
(let ((file-name (image-dired-original-file-name))
|
2021-12-09 03:28:19 +01:00
|
|
|
|
(dired-buf (buffer-name (image-dired-associated-dired-buffer)))
|
2022-09-24 10:45:37 +02:00
|
|
|
|
(image-count (format "%s/%s"
|
|
|
|
|
(get-text-property (point) 'image-number)
|
|
|
|
|
image-dired--number-of-thumbnails))
|
2022-09-13 18:54:14 +02:00
|
|
|
|
(props (string-join (get-text-property (point) 'tags) ", "))
|
2021-12-09 03:28:19 +01:00
|
|
|
|
(comment (get-text-property (point) 'comment))
|
|
|
|
|
(message-log-max nil))
|
2022-09-24 10:45:37 +02:00
|
|
|
|
(when file-name
|
|
|
|
|
(setq header-line-format
|
|
|
|
|
(image-dired-format-properties-string
|
|
|
|
|
dired-buf
|
|
|
|
|
file-name
|
|
|
|
|
image-count
|
|
|
|
|
props
|
|
|
|
|
comment))))))
|
2007-04-22 13:44:05 +00:00
|
|
|
|
|
2022-09-24 11:10:29 +02:00
|
|
|
|
|
|
|
|
|
;;; Marking and flagging
|
|
|
|
|
|
2021-11-03 22:34:51 +01:00
|
|
|
|
(defun image-dired-dired-file-marked-p (&optional marker)
|
|
|
|
|
"In Dired, return t if file on current line is marked.
|
|
|
|
|
If optional argument MARKER is non-nil, it is a character to look
|
|
|
|
|
for. The default is to look for `dired-marker-char'."
|
|
|
|
|
(setq marker (or marker dired-marker-char))
|
2007-04-22 13:44:05 +00:00
|
|
|
|
(save-excursion
|
|
|
|
|
(beginning-of-line)
|
2021-11-03 22:34:51 +01:00
|
|
|
|
(and (looking-at dired-re-mark)
|
|
|
|
|
(= (aref (match-string 0) 0) marker))))
|
|
|
|
|
|
|
|
|
|
(defun image-dired-dired-file-flagged-p ()
|
|
|
|
|
"In Dired, return t if file on current line is flagged for deletion."
|
|
|
|
|
(image-dired-dired-file-marked-p dired-del-marker))
|
2007-04-22 13:44:05 +00:00
|
|
|
|
|
2021-11-03 07:02:13 +01:00
|
|
|
|
(defmacro image-dired--on-file-in-dired-buffer (&rest body)
|
|
|
|
|
"Run BODY with point on file at point in Dired buffer.
|
|
|
|
|
Should be called from commands in `image-dired-thumbnail-mode'."
|
2021-12-07 23:28:44 +01:00
|
|
|
|
(declare (indent defun) (debug t))
|
2022-09-24 11:49:46 +02:00
|
|
|
|
`(if-let ((file-name (image-dired-original-file-name)))
|
|
|
|
|
(image-dired--with-dired-buffer
|
2021-11-03 07:02:13 +01:00
|
|
|
|
(when (dired-goto-file file-name)
|
2022-09-24 11:49:46 +02:00
|
|
|
|
,@body))
|
|
|
|
|
(message "No image with correct properties at point")))
|
2007-04-22 13:44:05 +00:00
|
|
|
|
|
2022-09-24 11:10:29 +02:00
|
|
|
|
(defmacro image-dired--with-thumbnail-buffer (&rest body)
|
|
|
|
|
(declare (indent defun) (debug t))
|
|
|
|
|
`(if-let ((buf (get-buffer image-dired-thumbnail-buffer)))
|
|
|
|
|
(with-current-buffer buf
|
|
|
|
|
(if-let ((win (get-buffer-window buf)))
|
|
|
|
|
(with-selected-window win
|
|
|
|
|
,@body)
|
|
|
|
|
,@body))
|
|
|
|
|
(user-error "No such buffer: %s" image-dired-thumbnail-buffer)))
|
|
|
|
|
|
2022-09-24 12:44:11 +02:00
|
|
|
|
(defmacro image-dired--do-mark-command (maybe-next update-mark &rest body)
|
|
|
|
|
"Run BODY in Dired buffer.
|
|
|
|
|
Helper macro for the mark, unmark and flag commands.
|
|
|
|
|
|
2022-09-15 22:19:00 +02:00
|
|
|
|
If MAYBE-NEXT is non-nil, show next image according to
|
|
|
|
|
`image-dired-marking-shows-next'.
|
2022-09-24 12:44:11 +02:00
|
|
|
|
|
|
|
|
|
If UPDATE-MARK is non-nil, also update the mark in the thumbnail
|
|
|
|
|
buffer with `image-dired--thumb-update-mark-at-point'."
|
2021-12-09 00:57:34 +01:00
|
|
|
|
(declare (indent defun) (debug t))
|
|
|
|
|
`(image-dired--with-thumbnail-buffer
|
|
|
|
|
(image-dired--on-file-in-dired-buffer
|
|
|
|
|
,@body)
|
2022-09-24 12:44:11 +02:00
|
|
|
|
,(when update-mark
|
|
|
|
|
'(image-dired--thumb-update-mark-at-point))
|
2021-12-09 00:57:34 +01:00
|
|
|
|
,(when maybe-next
|
|
|
|
|
'(if image-dired-marking-shows-next
|
2022-10-04 17:36:09 +02:00
|
|
|
|
(image-dired-display-next)
|
2022-09-08 02:12:44 +02:00
|
|
|
|
(image-dired-forward-image)))))
|
2021-12-09 00:57:34 +01:00
|
|
|
|
|
2007-04-22 13:44:05 +00:00
|
|
|
|
(defun image-dired-mark-thumb-original-file ()
|
2021-10-27 04:53:41 +02:00
|
|
|
|
"Mark original image file in associated Dired buffer."
|
2022-10-04 17:36:09 +02:00
|
|
|
|
(interactive nil image-dired-thumbnail-mode image-dired-image-mode)
|
2022-09-15 22:19:00 +02:00
|
|
|
|
(image-dired--do-mark-command t t
|
2021-12-09 00:57:34 +01:00
|
|
|
|
(dired-mark 1)))
|
2007-04-22 13:44:05 +00:00
|
|
|
|
|
|
|
|
|
(defun image-dired-unmark-thumb-original-file ()
|
2021-10-27 04:53:41 +02:00
|
|
|
|
"Unmark original image file in associated Dired buffer."
|
2022-10-04 17:36:09 +02:00
|
|
|
|
(interactive nil image-dired-thumbnail-mode image-dired-image-mode)
|
2022-09-15 22:19:00 +02:00
|
|
|
|
(image-dired--do-mark-command t t
|
2021-12-09 00:57:34 +01:00
|
|
|
|
(dired-unmark 1)))
|
2007-04-22 13:44:05 +00:00
|
|
|
|
|
|
|
|
|
(defun image-dired-flag-thumb-original-file ()
|
2021-10-27 04:53:41 +02:00
|
|
|
|
"Flag original image file for deletion in associated Dired buffer."
|
2022-10-04 17:36:09 +02:00
|
|
|
|
(interactive nil image-dired-thumbnail-mode image-dired-image-mode)
|
2022-09-15 22:19:00 +02:00
|
|
|
|
(image-dired--do-mark-command t t
|
2021-12-09 00:57:34 +01:00
|
|
|
|
(dired-flag-file-deletion 1)))
|
2007-04-22 13:44:05 +00:00
|
|
|
|
|
2021-10-01 14:49:28 +02:00
|
|
|
|
(defun image-dired-unmark-all-marks ()
|
2021-11-03 07:14:21 +01:00
|
|
|
|
"Remove all marks from all files in associated Dired buffer.
|
|
|
|
|
Also update the marks in the thumbnail buffer."
|
2022-10-04 17:36:09 +02:00
|
|
|
|
(interactive nil image-dired-thumbnail-mode image-dired-image-mode)
|
2022-09-15 22:19:00 +02:00
|
|
|
|
(image-dired--do-mark-command nil t
|
2021-12-09 00:57:34 +01:00
|
|
|
|
(dired-unmark-all-marks))
|
2021-12-07 23:28:44 +01:00
|
|
|
|
(image-dired--with-thumbnail-buffer
|
2022-09-24 12:44:11 +02:00
|
|
|
|
(image-dired--thumb-update-marks)))
|
2021-10-01 14:49:28 +02:00
|
|
|
|
|
2007-04-22 13:44:05 +00:00
|
|
|
|
(defun image-dired-jump-original-dired-buffer ()
|
2021-10-27 04:53:41 +02:00
|
|
|
|
"Jump to the Dired buffer associated with the current image file.
|
2007-04-22 13:44:05 +00:00
|
|
|
|
You probably want to use this together with
|
|
|
|
|
`image-dired-track-original-file'."
|
2021-10-28 02:10:09 +02:00
|
|
|
|
(interactive nil image-dired-thumbnail-mode)
|
2022-09-24 11:49:46 +02:00
|
|
|
|
(image-dired--with-dired-buffer
|
|
|
|
|
(if-let ((window (image-dired-get-buffer-window (current-buffer))))
|
2007-04-22 13:44:05 +00:00
|
|
|
|
(progn
|
2022-09-24 11:49:46 +02:00
|
|
|
|
(if (not (equal (selected-frame) (window-frame window)))
|
|
|
|
|
(select-frame-set-input-focus (window-frame window)))
|
2007-04-22 13:44:05 +00:00
|
|
|
|
(select-window window))
|
2022-09-24 11:49:46 +02:00
|
|
|
|
(message "Associated Dired buffer not visible"))))
|
2007-04-22 13:44:05 +00:00
|
|
|
|
|
2022-09-24 11:10:29 +02:00
|
|
|
|
|
|
|
|
|
;;; Major modes
|
|
|
|
|
|
2022-08-30 19:05:29 +02:00
|
|
|
|
(defvar-keymap image-dired-thumbnail-mode-map
|
|
|
|
|
:doc "Keymap for `image-dired-thumbnail-mode'."
|
|
|
|
|
"d" #'image-dired-flag-thumb-original-file
|
|
|
|
|
"<delete>" #'image-dired-flag-thumb-original-file
|
|
|
|
|
"m" #'image-dired-mark-thumb-original-file
|
|
|
|
|
"u" #'image-dired-unmark-thumb-original-file
|
|
|
|
|
"U" #'image-dired-unmark-all-marks
|
2022-09-29 01:39:30 +02:00
|
|
|
|
"x" #'image-dired-do-flagged-delete
|
2022-08-30 19:05:29 +02:00
|
|
|
|
"." #'image-dired-track-original-file
|
|
|
|
|
"<tab>" #'image-dired-jump-original-dired-buffer
|
|
|
|
|
|
|
|
|
|
"g g" #'image-dired-line-up-dynamic
|
|
|
|
|
"g f" #'image-dired-line-up
|
|
|
|
|
"g i" #'image-dired-line-up-interactive
|
|
|
|
|
|
|
|
|
|
"t t" #'image-dired-tag-thumbnail
|
|
|
|
|
"t r" #'image-dired-tag-thumbnail-remove
|
|
|
|
|
|
2022-10-04 17:36:09 +02:00
|
|
|
|
"RET" #'image-dired-display-this
|
2022-08-30 19:05:29 +02:00
|
|
|
|
"C-<return>" #'image-dired-thumbnail-display-external
|
|
|
|
|
|
|
|
|
|
"L" #'image-dired-rotate-original-left
|
|
|
|
|
"R" #'image-dired-rotate-original-right
|
|
|
|
|
|
|
|
|
|
"D" #'image-dired-thumbnail-set-image-description
|
|
|
|
|
"S" #'image-dired-slideshow-start
|
|
|
|
|
"C-d" #'image-dired-delete-char
|
2022-10-04 17:36:09 +02:00
|
|
|
|
"SPC" #'image-dired-display-next
|
|
|
|
|
"DEL" #'image-dired-display-previous
|
2022-08-30 19:05:29 +02:00
|
|
|
|
"c" #'image-dired-comment-thumbnail
|
2022-09-25 00:37:40 +02:00
|
|
|
|
"w" #'image-dired-copy-filename-as-kill
|
2022-09-13 17:56:22 +02:00
|
|
|
|
"W" #'image-dired-wallpaper-set
|
2022-08-30 19:05:29 +02:00
|
|
|
|
|
|
|
|
|
;; Mouse
|
|
|
|
|
"<mouse-2>" #'image-dired-mouse-display-image
|
2022-09-18 02:17:31 +02:00
|
|
|
|
"<double-mouse-1>" #'image-dired-mouse-display-image
|
2022-08-30 19:05:29 +02:00
|
|
|
|
"<mouse-1>" #'image-dired-mouse-select-thumbnail
|
|
|
|
|
"<mouse-3>" #'image-dired-mouse-select-thumbnail
|
|
|
|
|
"<down-mouse-1>" #'image-dired-mouse-select-thumbnail
|
|
|
|
|
"<down-mouse-2>" #'image-dired-mouse-select-thumbnail
|
|
|
|
|
"<down-mouse-3>" #'image-dired-mouse-select-thumbnail
|
2022-09-18 02:10:01 +02:00
|
|
|
|
"C-<down-mouse-1>" #'ignore ; Don't open the buffer menu.
|
2022-09-24 13:36:39 +02:00
|
|
|
|
"C-<mouse-1>" #'image-dired-mouse-toggle-mark
|
|
|
|
|
|
2022-09-24 14:07:55 +02:00
|
|
|
|
"<remap> <forward-char>" #'image-dired-forward-image
|
|
|
|
|
"<remap> <backward-char>" #'image-dired-backward-image
|
|
|
|
|
"<remap> <next-line>" #'image-dired-next-line
|
|
|
|
|
"<remap> <previous-line>" #'image-dired-previous-line
|
2022-10-04 16:18:13 +02:00
|
|
|
|
"<remap> <left-char>" #'image-dired-backward-image
|
|
|
|
|
"<remap> <right-char>" #'image-dired-forward-image
|
2022-09-24 14:07:55 +02:00
|
|
|
|
"<remap> <beginning-of-buffer>" #'image-dired-beginning-of-buffer
|
|
|
|
|
"<remap> <end-of-buffer>" #'image-dired-end-of-buffer
|
2022-09-24 13:36:39 +02:00
|
|
|
|
"<remap> <move-beginning-of-line>" #'image-dired-move-beginning-of-line
|
2022-09-24 18:27:35 +02:00
|
|
|
|
"<remap> <move-end-of-line>" #'image-dired-move-end-of-line
|
2007-04-22 13:44:05 +00:00
|
|
|
|
|
2022-09-24 18:27:35 +02:00
|
|
|
|
:menu
|
2021-11-03 02:39:00 +01:00
|
|
|
|
'("Image-Dired"
|
2022-10-04 17:36:09 +02:00
|
|
|
|
["Display image" image-dired-display-this]
|
2021-11-03 02:39:00 +01:00
|
|
|
|
["Display in external viewer" image-dired-thumbnail-display-external]
|
2021-11-12 03:51:21 +01:00
|
|
|
|
["Jump to Dired buffer" image-dired-jump-original-dired-buffer]
|
2021-11-03 03:00:23 +01:00
|
|
|
|
"---"
|
2021-11-12 03:51:21 +01:00
|
|
|
|
["Mark image" image-dired-mark-thumb-original-file]
|
|
|
|
|
["Unmark image" image-dired-unmark-thumb-original-file]
|
|
|
|
|
["Unmark all images" image-dired-unmark-all-marks]
|
|
|
|
|
["Flag for deletion" image-dired-flag-thumb-original-file]
|
2022-09-29 01:39:30 +02:00
|
|
|
|
["Delete flagged images" image-dired-do-flagged-delete]
|
2021-11-03 03:00:23 +01:00
|
|
|
|
"---"
|
2021-11-03 02:39:00 +01:00
|
|
|
|
["Rotate original right" image-dired-rotate-original-right]
|
|
|
|
|
["Rotate original left" image-dired-rotate-original-left]
|
2021-11-03 03:00:23 +01:00
|
|
|
|
"---"
|
2021-11-03 02:39:00 +01:00
|
|
|
|
["Comment thumbnail" image-dired-comment-thumbnail]
|
|
|
|
|
["Tag current or marked thumbnails" image-dired-tag-thumbnail]
|
|
|
|
|
["Remove tag from current or marked thumbnails"
|
|
|
|
|
image-dired-tag-thumbnail-remove]
|
2021-11-12 04:10:40 +01:00
|
|
|
|
["Start slideshow" image-dired-slideshow-start]
|
2021-11-03 03:00:23 +01:00
|
|
|
|
"---"
|
2021-11-12 03:51:21 +01:00
|
|
|
|
("View Options"
|
|
|
|
|
["Toggle movement tracking" image-dired-toggle-movement-tracking
|
|
|
|
|
:style toggle
|
|
|
|
|
:selected image-dired-track-movement]
|
|
|
|
|
"---"
|
|
|
|
|
["Line up thumbnails" image-dired-line-up]
|
|
|
|
|
["Dynamic line up" image-dired-line-up-dynamic]
|
|
|
|
|
["Refresh thumb" image-dired-refresh-thumb])
|
2021-11-03 02:39:00 +01:00
|
|
|
|
["Quit" quit-window]))
|
|
|
|
|
|
2007-04-22 13:44:05 +00:00
|
|
|
|
(define-derived-mode image-dired-thumbnail-mode
|
2016-12-15 13:49:38 -05:00
|
|
|
|
special-mode "image-dired-thumbnail"
|
2021-10-27 04:53:41 +02:00
|
|
|
|
"Browse and manipulate thumbnail images using Dired.
|
2016-12-13 11:32:04 -05:00
|
|
|
|
Use `image-dired-minor-mode' to get a nice setup."
|
2021-11-12 04:27:11 +01:00
|
|
|
|
:interactive nil
|
2022-09-21 08:27:42 +02:00
|
|
|
|
:group 'image-dired
|
2016-12-13 22:56:42 -05:00
|
|
|
|
(buffer-disable-undo)
|
2021-10-27 06:05:39 +02:00
|
|
|
|
(add-hook 'file-name-at-point-functions 'image-dired-file-name-at-point nil t)
|
2021-11-08 06:20:21 +01:00
|
|
|
|
(setq-local window-resize-pixelwise t)
|
2021-10-27 07:51:35 +02:00
|
|
|
|
(setq-local bookmark-make-record-function #'image-dired-bookmark-make-record)
|
|
|
|
|
;; Use approximately as much vertical spacing as horizontal.
|
|
|
|
|
(setq-local line-spacing (frame-char-width)))
|
2007-04-22 13:44:05 +00:00
|
|
|
|
|
2022-10-04 17:36:09 +02:00
|
|
|
|
|
|
|
|
|
;;; image-dired-image-mode
|
|
|
|
|
|
|
|
|
|
(define-obsolete-variable-alias 'image-dired-display-image-mode-map
|
|
|
|
|
'image-dired-image-mode-map "29.1")
|
|
|
|
|
(defvar-keymap image-dired-image-mode-map
|
|
|
|
|
:doc "Keymap for `image-dired-image-mode'."
|
|
|
|
|
"S" #'image-dired-slideshow-start
|
|
|
|
|
"SPC" #'image-dired-display-next
|
|
|
|
|
"DEL" #'image-dired-display-previous
|
|
|
|
|
"n" #'image-dired-display-next
|
|
|
|
|
"p" #'image-dired-display-previous
|
|
|
|
|
"m" #'image-dired-mark-thumb-original-file
|
|
|
|
|
"d" #'image-dired-flag-thumb-original-file
|
|
|
|
|
"u" #'image-dired-unmark-thumb-original-file
|
|
|
|
|
"U" #'image-dired-unmark-all-marks
|
|
|
|
|
;; Disable keybindings from `image-mode-map' that doesn't make sense here.
|
|
|
|
|
"o" nil) ; image-save
|
|
|
|
|
|
|
|
|
|
(define-derived-mode image-dired-image-mode
|
2021-11-04 02:05:29 +01:00
|
|
|
|
image-mode "image-dired-image-display"
|
2007-04-22 13:44:05 +00:00
|
|
|
|
"Mode for displaying and manipulating original image.
|
|
|
|
|
Resized or in full-size."
|
2021-11-04 02:05:29 +01:00
|
|
|
|
:interactive nil
|
2022-09-21 08:27:42 +02:00
|
|
|
|
:group 'image-dired
|
2022-09-24 10:45:37 +02:00
|
|
|
|
(setq-local column-number-mode nil)
|
|
|
|
|
(setq-local line-number-mode nil)
|
2021-11-04 02:05:29 +01:00
|
|
|
|
(add-hook 'file-name-at-point-functions #'image-dired-file-name-at-point nil t))
|
2007-04-22 13:44:05 +00:00
|
|
|
|
|
2021-11-08 06:42:44 +01:00
|
|
|
|
|
2021-11-12 04:10:40 +01:00
|
|
|
|
;;; Slideshow
|
2021-11-08 06:42:44 +01:00
|
|
|
|
|
2021-11-12 04:10:40 +01:00
|
|
|
|
(defcustom image-dired-slideshow-delay 5.0
|
|
|
|
|
"Seconds to wait before showing the next image in a slideshow.
|
|
|
|
|
This is used by `image-dired-slideshow-start'."
|
|
|
|
|
:type 'float
|
|
|
|
|
:version "29.1")
|
2007-04-22 13:44:05 +00:00
|
|
|
|
|
2021-11-12 04:10:40 +01:00
|
|
|
|
(define-obsolete-variable-alias 'image-dired-slideshow-timer
|
|
|
|
|
'image-dired--slideshow-timer "29.1")
|
|
|
|
|
(defvar image-dired--slideshow-timer nil
|
|
|
|
|
"Slideshow timer.")
|
2007-04-22 13:44:05 +00:00
|
|
|
|
|
2022-09-23 23:12:10 +02:00
|
|
|
|
(defvar image-dired--slideshow-current-delay image-dired-slideshow-delay)
|
2007-04-22 13:44:05 +00:00
|
|
|
|
|
2022-09-23 20:18:17 +02:00
|
|
|
|
(defun image-dired--slideshow-step ()
|
2022-09-23 23:12:10 +02:00
|
|
|
|
"Step to the next image in a slideshow."
|
2021-11-12 04:10:40 +01:00
|
|
|
|
(if-let ((buf (get-buffer image-dired-thumbnail-buffer)))
|
|
|
|
|
(with-current-buffer buf
|
2022-10-04 17:36:09 +02:00
|
|
|
|
(image-dired-display-next))
|
2022-09-23 20:18:17 +02:00
|
|
|
|
(image-dired--slideshow-stop)))
|
2007-04-22 13:44:05 +00:00
|
|
|
|
|
2022-09-23 23:12:10 +02:00
|
|
|
|
(defun image-dired--slideshow-start-timer ()
|
|
|
|
|
(image-dired--slideshow-stop-timer)
|
|
|
|
|
(setq image-dired--slideshow-timer
|
|
|
|
|
(run-with-timer image-dired--slideshow-current-delay
|
|
|
|
|
image-dired--slideshow-current-delay
|
|
|
|
|
'image-dired--slideshow-step)))
|
|
|
|
|
|
|
|
|
|
(defun image-dired--slideshow-stop-timer ()
|
|
|
|
|
(when image-dired--slideshow-timer
|
|
|
|
|
(cancel-timer image-dired--slideshow-timer)
|
|
|
|
|
(setq image-dired--slideshow-timer nil)))
|
|
|
|
|
|
2021-11-12 04:10:40 +01:00
|
|
|
|
(defun image-dired-slideshow-start (&optional arg)
|
2022-09-23 23:12:10 +02:00
|
|
|
|
"Start a slideshow, waiting `image-dired-slideshow-delay' seconds between images.
|
2021-11-12 04:10:40 +01:00
|
|
|
|
|
|
|
|
|
With prefix argument ARG, wait that many seconds before going to
|
|
|
|
|
the next image.
|
|
|
|
|
|
|
|
|
|
With a negative prefix argument, prompt user for the delay."
|
2022-10-04 17:36:09 +02:00
|
|
|
|
(interactive "P" image-dired-thumbnail-mode image-dired-image-mode)
|
2022-09-23 23:12:10 +02:00
|
|
|
|
(let ((delay
|
|
|
|
|
(cond ((not arg)
|
|
|
|
|
image-dired-slideshow-delay)
|
|
|
|
|
((> arg 0)
|
|
|
|
|
arg)
|
|
|
|
|
((<= arg 0)
|
|
|
|
|
(string-to-number
|
|
|
|
|
(let ((delay (number-to-string image-dired-slideshow-delay)))
|
|
|
|
|
(read-string
|
|
|
|
|
(format-prompt "Delay, in seconds. Decimals are accepted"
|
|
|
|
|
delay))
|
|
|
|
|
delay))))))
|
2022-10-04 17:36:09 +02:00
|
|
|
|
(image-dired-display-this)
|
2022-09-23 23:12:10 +02:00
|
|
|
|
(setq image-dired--slideshow-current-delay delay)
|
|
|
|
|
(add-hook 'post-command-hook 'image-dired--slideshow-stop)))
|
|
|
|
|
|
|
|
|
|
(defun image-dired--slideshow-show-message (&optional suffix)
|
|
|
|
|
"Helper function for `image-dired--slideshow-stop'."
|
|
|
|
|
(message (substitute-command-keys
|
|
|
|
|
(format
|
|
|
|
|
(concat
|
2022-10-04 17:36:09 +02:00
|
|
|
|
"\\[image-dired-display-next] next, "
|
|
|
|
|
"\\[image-dired-display-previous] previous, "
|
|
|
|
|
"\\[image-dired-display-this] pause/unpause, "
|
2022-09-23 23:12:10 +02:00
|
|
|
|
"any other command to stop%s")
|
|
|
|
|
(or suffix "")))))
|
2007-04-22 13:44:05 +00:00
|
|
|
|
|
2022-09-23 20:18:17 +02:00
|
|
|
|
(defun image-dired--slideshow-stop ()
|
2022-09-23 23:12:10 +02:00
|
|
|
|
"Cancel the currently active slideshow."
|
|
|
|
|
(cond
|
|
|
|
|
((memq this-command
|
|
|
|
|
'( image-dired-slideshow-start
|
2022-10-04 17:36:09 +02:00
|
|
|
|
image-dired-display-next
|
|
|
|
|
image-dired-display-previous))
|
2022-09-23 23:12:10 +02:00
|
|
|
|
(image-dired--slideshow-start-timer)
|
|
|
|
|
(image-dired--slideshow-show-message))
|
2022-10-04 17:36:09 +02:00
|
|
|
|
((eq this-command 'image-dired-display-this)
|
2022-09-23 23:12:10 +02:00
|
|
|
|
(let ((pause image-dired--slideshow-timer))
|
|
|
|
|
(if pause
|
|
|
|
|
(image-dired--slideshow-stop-timer)
|
|
|
|
|
(image-dired--slideshow-start-timer))
|
|
|
|
|
(image-dired--slideshow-show-message (and pause " [PAUSED]"))))
|
|
|
|
|
(t
|
|
|
|
|
(image-dired--slideshow-stop-timer)
|
|
|
|
|
(remove-hook 'post-command-hook 'image-dired--slideshow-stop))))
|
2007-04-22 13:44:05 +00:00
|
|
|
|
|
2021-11-08 06:42:44 +01:00
|
|
|
|
|
2022-09-24 11:10:29 +02:00
|
|
|
|
;;; Thumbnail layout and display
|
2021-11-08 06:42:44 +01:00
|
|
|
|
|
2007-04-22 13:44:05 +00:00
|
|
|
|
(defun image-dired-delete-char ()
|
|
|
|
|
"Remove current thumbnail from thumbnail buffer and line up."
|
2021-10-28 02:10:09 +02:00
|
|
|
|
(interactive nil image-dired-thumbnail-mode)
|
2007-04-22 13:44:05 +00:00
|
|
|
|
(let ((inhibit-read-only t))
|
2022-09-29 01:25:10 +02:00
|
|
|
|
(delete-char 1))
|
|
|
|
|
(let ((pos (point)))
|
|
|
|
|
(image-dired--line-up-with-method)
|
|
|
|
|
(goto-char pos)))
|
2007-04-22 13:44:05 +00:00
|
|
|
|
|
|
|
|
|
(defun image-dired-line-up ()
|
|
|
|
|
"Line up thumbnails according to `image-dired-thumbs-per-row'.
|
|
|
|
|
See also `image-dired-line-up-dynamic'."
|
2022-08-20 22:44:14 +02:00
|
|
|
|
(interactive nil image-dired-thumbnail-mode)
|
2007-04-22 13:44:05 +00:00
|
|
|
|
(let ((inhibit-read-only t))
|
|
|
|
|
(goto-char (point-min))
|
|
|
|
|
(while (and (not (image-dired-image-at-point-p))
|
|
|
|
|
(not (eobp)))
|
|
|
|
|
(delete-char 1))
|
|
|
|
|
(while (not (eobp))
|
|
|
|
|
(forward-char)
|
|
|
|
|
(while (and (not (image-dired-image-at-point-p))
|
|
|
|
|
(not (eobp)))
|
|
|
|
|
(delete-char 1)))
|
|
|
|
|
(goto-char (point-min))
|
2021-10-27 02:36:57 +02:00
|
|
|
|
(let ((seen 0)
|
|
|
|
|
(thumb-prev-pos 0)
|
|
|
|
|
(thumb-width-chars
|
|
|
|
|
(ceiling (/ (+ (* 2 image-dired-thumb-relief)
|
|
|
|
|
(* 2 image-dired-thumb-margin)
|
2022-09-17 21:27:38 +02:00
|
|
|
|
(image-dired--thumb-size))
|
2021-10-27 02:36:57 +02:00
|
|
|
|
(float (frame-char-width))))))
|
2007-04-22 13:44:05 +00:00
|
|
|
|
(while (not (eobp))
|
|
|
|
|
(forward-char)
|
|
|
|
|
(if (= image-dired-thumbs-per-row 1)
|
|
|
|
|
(insert "\n")
|
2021-10-27 02:36:57 +02:00
|
|
|
|
(cl-incf thumb-prev-pos thumb-width-chars)
|
|
|
|
|
(insert (propertize " " 'display `(space :align-to ,thumb-prev-pos)))
|
|
|
|
|
(cl-incf seen)
|
|
|
|
|
(when (and (= seen (- image-dired-thumbs-per-row 1))
|
2022-08-23 14:59:47 +02:00
|
|
|
|
(not (eobp)))
|
2007-04-22 13:44:05 +00:00
|
|
|
|
(forward-char)
|
|
|
|
|
(insert "\n")
|
2021-10-27 02:36:57 +02:00
|
|
|
|
(setq seen 0)
|
|
|
|
|
(setq thumb-prev-pos 0)))))
|
2007-04-22 13:44:05 +00:00
|
|
|
|
(goto-char (point-min))))
|
|
|
|
|
|
|
|
|
|
(defun image-dired-line-up-dynamic ()
|
|
|
|
|
"Line up thumbnails images dynamically.
|
|
|
|
|
Calculate how many thumbnails fit."
|
2022-08-20 22:44:14 +02:00
|
|
|
|
(interactive nil image-dired-thumbnail-mode)
|
2007-04-22 13:44:05 +00:00
|
|
|
|
(let* ((char-width (frame-char-width))
|
2022-08-31 05:52:11 +02:00
|
|
|
|
(width (window-body-width (image-dired-thumbnail-window) t))
|
|
|
|
|
(image-dired-thumbs-per-row
|
|
|
|
|
(/ width
|
|
|
|
|
(+ (* 2 image-dired-thumb-relief)
|
|
|
|
|
(* 2 image-dired-thumb-margin)
|
2022-09-17 21:27:38 +02:00
|
|
|
|
(image-dired--thumb-size)
|
2022-08-31 05:52:11 +02:00
|
|
|
|
char-width))))
|
2007-04-22 13:44:05 +00:00
|
|
|
|
(image-dired-line-up)))
|
|
|
|
|
|
|
|
|
|
(defun image-dired-line-up-interactive ()
|
|
|
|
|
"Line up thumbnails interactively.
|
|
|
|
|
Ask user how many thumbnails should be displayed per row."
|
2022-08-20 22:44:14 +02:00
|
|
|
|
(interactive nil image-dired-thumbnail-mode)
|
2007-04-22 13:44:05 +00:00
|
|
|
|
(let ((image-dired-thumbs-per-row
|
|
|
|
|
(string-to-number (read-string "How many thumbs per row: "))))
|
|
|
|
|
(if (not (> image-dired-thumbs-per-row 0))
|
|
|
|
|
(message "Number must be greater than 0")
|
|
|
|
|
(image-dired-line-up))))
|
|
|
|
|
|
2022-09-24 11:10:29 +02:00
|
|
|
|
|
|
|
|
|
;;; Display image from thumbnail buffer
|
|
|
|
|
|
2007-04-22 13:44:05 +00:00
|
|
|
|
(defun image-dired-thumbnail-display-external ()
|
|
|
|
|
"Display original image for thumbnail at point using external viewer."
|
2022-08-20 22:44:14 +02:00
|
|
|
|
(interactive nil image-dired-thumbnail-mode)
|
2007-04-22 13:44:05 +00:00
|
|
|
|
(let ((file (image-dired-original-file-name)))
|
|
|
|
|
(if (not (image-dired-image-at-point-p))
|
|
|
|
|
(message "No thumbnail at point")
|
|
|
|
|
(if (not file)
|
|
|
|
|
(message "No original file name found")
|
2022-09-24 11:06:51 +02:00
|
|
|
|
(apply #'start-process "image-dired-thumb-external" nil
|
|
|
|
|
(append (string-split image-dired-external-viewer " ")
|
|
|
|
|
(list file)))))))
|
2007-04-22 13:44:05 +00:00
|
|
|
|
|
2021-11-04 02:05:29 +01:00
|
|
|
|
(defun image-dired-display-image (file &optional _ignored)
|
2022-09-23 23:47:23 +02:00
|
|
|
|
"Display image FILE in the image buffer window.
|
2022-10-04 17:36:09 +02:00
|
|
|
|
If it is an image, the window will use `image-dired-image-mode'
|
2022-09-16 21:54:29 +02:00
|
|
|
|
which is based on `image-mode'."
|
2021-11-04 02:05:29 +01:00
|
|
|
|
(declare (advertised-calling-convention (file) "29.1"))
|
|
|
|
|
(setq file (expand-file-name file))
|
|
|
|
|
(when (not (file-exists-p file))
|
|
|
|
|
(error "No such file: %s" file))
|
|
|
|
|
(let ((buf (get-buffer image-dired-display-image-buffer))
|
|
|
|
|
(cur-win (selected-window)))
|
|
|
|
|
(when buf
|
|
|
|
|
(kill-buffer buf))
|
2022-08-19 01:51:42 +02:00
|
|
|
|
(when-let ((buf (find-file-noselect file nil t)))
|
|
|
|
|
(pop-to-buffer buf)
|
2021-11-04 02:05:29 +01:00
|
|
|
|
(rename-buffer image-dired-display-image-buffer)
|
2022-09-16 21:54:29 +02:00
|
|
|
|
(if (string-match (image-file-name-regexp) file)
|
2022-10-04 17:36:09 +02:00
|
|
|
|
(image-dired-image-mode)
|
2022-09-16 21:54:29 +02:00
|
|
|
|
;; Support visiting PDF files.
|
|
|
|
|
(normal-mode))
|
2021-11-04 02:05:29 +01:00
|
|
|
|
(select-window cur-win))))
|
2007-04-22 13:44:05 +00:00
|
|
|
|
|
2022-10-04 17:36:09 +02:00
|
|
|
|
(defun image-dired-display-this (&optional arg)
|
2007-04-22 13:44:05 +00:00
|
|
|
|
"Display current thumbnail's original image in display buffer.
|
|
|
|
|
See documentation for `image-dired-display-image' for more information.
|
|
|
|
|
With prefix argument ARG, display image in its original size."
|
2022-08-20 22:44:14 +02:00
|
|
|
|
(interactive "P" image-dired-thumbnail-mode)
|
2022-09-16 21:54:29 +02:00
|
|
|
|
(unless (string-equal major-mode "image-dired-thumbnail-mode")
|
|
|
|
|
(user-error "Not in `image-dired-thumbnail-mode'"))
|
2007-04-22 13:44:05 +00:00
|
|
|
|
(let ((file (image-dired-original-file-name)))
|
2022-09-16 21:54:29 +02:00
|
|
|
|
(cond ((not (image-dired-image-at-point-p))
|
|
|
|
|
(message "No thumbnail at point"))
|
|
|
|
|
((not file)
|
|
|
|
|
(message "No original file name found"))
|
|
|
|
|
(t
|
|
|
|
|
(image-dired-display-image file arg)))))
|
2007-04-22 13:44:05 +00:00
|
|
|
|
|
2022-10-04 17:36:09 +02:00
|
|
|
|
(defun image-dired-display-next (&optional arg)
|
2022-09-24 11:10:29 +02:00
|
|
|
|
"Move to the next image in the thumbnail buffer and display it.
|
|
|
|
|
With prefix ARG, move that many thumbnails."
|
2022-10-04 17:36:09 +02:00
|
|
|
|
(interactive "p" image-dired-thumbnail-mode image-dired-image-mode)
|
2022-09-24 11:10:29 +02:00
|
|
|
|
(image-dired--with-thumbnail-buffer
|
|
|
|
|
(image-dired-forward-image arg t)
|
2022-10-04 17:36:09 +02:00
|
|
|
|
(image-dired-display-this)))
|
2022-09-24 11:10:29 +02:00
|
|
|
|
|
2022-10-04 17:36:09 +02:00
|
|
|
|
(defun image-dired-display-previous (arg)
|
2022-09-24 11:10:29 +02:00
|
|
|
|
"Move to the previous image in the thumbnail buffer and display it.
|
|
|
|
|
With prefix ARG, move that many thumbnails."
|
2022-10-04 17:36:09 +02:00
|
|
|
|
(interactive "p" image-dired-thumbnail-mode image-dired-image-mode)
|
|
|
|
|
(image-dired-display-next (- arg)))
|
2022-09-24 11:10:29 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
;;; Misc commands
|
|
|
|
|
|
2007-04-22 13:44:05 +00:00
|
|
|
|
(defun image-dired-rotate-original-left ()
|
2020-01-22 17:05:03 +01:00
|
|
|
|
"Rotate original image left (counter clockwise) 90 degrees.
|
|
|
|
|
The result of the rotation is displayed in the image display area
|
|
|
|
|
and a confirmation is needed before the original image files is
|
|
|
|
|
overwritten. This confirmation can be turned off using
|
|
|
|
|
`image-dired-rotate-original-ask-before-overwrite'."
|
2022-08-20 22:44:14 +02:00
|
|
|
|
(interactive nil image-dired-thumbnail-mode)
|
2022-09-08 02:09:52 +02:00
|
|
|
|
(image-dired--with-marked
|
|
|
|
|
(image-dired-rotate-original "270")))
|
2007-04-22 13:44:05 +00:00
|
|
|
|
|
|
|
|
|
(defun image-dired-rotate-original-right ()
|
2020-01-22 17:05:03 +01:00
|
|
|
|
"Rotate original image right (clockwise) 90 degrees.
|
|
|
|
|
The result of the rotation is displayed in the image display area
|
|
|
|
|
and a confirmation is needed before the original image files is
|
|
|
|
|
overwritten. This confirmation can be turned off using
|
|
|
|
|
`image-dired-rotate-original-ask-before-overwrite'."
|
2022-08-20 22:44:14 +02:00
|
|
|
|
(interactive nil image-dired-thumbnail-mode)
|
2022-09-08 02:09:52 +02:00
|
|
|
|
(image-dired--with-marked
|
|
|
|
|
(image-dired-rotate-original "90")))
|
2007-04-22 13:44:05 +00:00
|
|
|
|
|
2022-09-13 17:56:22 +02:00
|
|
|
|
(defun image-dired-wallpaper-set (file)
|
|
|
|
|
"Set the wallpaper to FILE in a graphical environment."
|
|
|
|
|
(interactive (list (image-dired-original-file-name))
|
|
|
|
|
image-dired-thumbnail-mode)
|
|
|
|
|
(wallpaper-set file))
|
|
|
|
|
|
2007-04-22 13:44:05 +00:00
|
|
|
|
(defun image-dired-comment-thumbnail ()
|
|
|
|
|
"Add comment to current thumbnail in thumbnail buffer."
|
2022-09-23 23:47:23 +02:00
|
|
|
|
(interactive nil image-dired-thumbnail-mode)
|
2007-04-22 13:44:05 +00:00
|
|
|
|
(let* ((file (image-dired-original-file-name))
|
|
|
|
|
(comment (image-dired-read-comment file)))
|
|
|
|
|
(image-dired-write-comments (list (cons file comment)))
|
|
|
|
|
(image-dired-update-property 'comment comment))
|
2022-09-24 10:45:37 +02:00
|
|
|
|
(image-dired--update-header-line))
|
2007-04-22 13:44:05 +00:00
|
|
|
|
|
2022-09-25 00:37:40 +02:00
|
|
|
|
(defun image-dired-copy-filename-as-kill (&optional arg)
|
|
|
|
|
"Copy names of marked (or next ARG) files into the kill ring.
|
|
|
|
|
This works as `dired-copy-filename-as-kill' (which see)."
|
|
|
|
|
(interactive "P" image-dired-thumbnail-mode)
|
|
|
|
|
(image-dired--with-dired-buffer
|
|
|
|
|
(dired-copy-filename-as-kill arg)))
|
|
|
|
|
|
2021-11-08 06:42:44 +01:00
|
|
|
|
|
|
|
|
|
;;; Mouse support
|
|
|
|
|
|
2007-04-22 13:44:05 +00:00
|
|
|
|
(defun image-dired-mouse-display-image (event)
|
|
|
|
|
"Use mouse EVENT, call `image-dired-display-image' to display image.
|
2021-10-27 04:53:41 +02:00
|
|
|
|
Track this in associated Dired buffer if `image-dired-track-movement' is
|
2007-04-22 13:44:05 +00:00
|
|
|
|
non-nil."
|
|
|
|
|
(interactive "e")
|
2011-01-28 13:09:59 -05:00
|
|
|
|
(mouse-set-point event)
|
|
|
|
|
(goto-char (posn-point (event-end event)))
|
2021-10-27 04:34:25 +02:00
|
|
|
|
(unless (image-at-point-p)
|
|
|
|
|
(image-dired-backward-image))
|
2011-01-28 13:09:59 -05:00
|
|
|
|
(let ((file (image-dired-original-file-name)))
|
|
|
|
|
(when file
|
|
|
|
|
(if image-dired-track-movement
|
2022-08-23 14:59:47 +02:00
|
|
|
|
(image-dired-track-original-file))
|
2011-01-28 13:09:59 -05:00
|
|
|
|
(image-dired-display-image file))))
|
2007-04-22 13:44:05 +00:00
|
|
|
|
|
|
|
|
|
(defun image-dired-mouse-select-thumbnail (event)
|
|
|
|
|
"Use mouse EVENT to select thumbnail image.
|
2021-10-27 04:53:41 +02:00
|
|
|
|
Track this in associated Dired buffer if `image-dired-track-movement' is
|
2007-04-22 13:44:05 +00:00
|
|
|
|
non-nil."
|
|
|
|
|
(interactive "e")
|
2011-04-19 15:44:55 +02:00
|
|
|
|
(mouse-set-point event)
|
|
|
|
|
(goto-char (posn-point (event-end event)))
|
2021-10-27 04:34:25 +02:00
|
|
|
|
(unless (image-at-point-p)
|
|
|
|
|
(image-dired-backward-image))
|
2011-04-19 15:44:55 +02:00
|
|
|
|
(if image-dired-track-movement
|
|
|
|
|
(image-dired-track-original-file))
|
2022-09-24 10:45:37 +02:00
|
|
|
|
(image-dired--update-header-line))
|
2007-04-22 13:44:05 +00:00
|
|
|
|
|
2021-11-08 06:42:44 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
;;; Dired marks and tags
|
|
|
|
|
|
2021-11-03 22:34:51 +01:00
|
|
|
|
(defun image-dired-thumb-file-marked-p (&optional flagged)
|
|
|
|
|
"Check if file is marked in associated Dired buffer.
|
|
|
|
|
If optional argument FLAGGED is non-nil, check if file is flagged
|
|
|
|
|
for deletion instead."
|
2022-09-24 11:49:46 +02:00
|
|
|
|
(let ((file-name (image-dired-original-file-name)))
|
|
|
|
|
(image-dired--with-dired-buffer
|
|
|
|
|
(save-excursion
|
|
|
|
|
(when (dired-goto-file file-name)
|
|
|
|
|
(if flagged
|
|
|
|
|
(image-dired-dired-file-flagged-p)
|
|
|
|
|
(image-dired-dired-file-marked-p)))))))
|
2021-11-03 22:34:51 +01:00
|
|
|
|
|
|
|
|
|
(defun image-dired-thumb-file-flagged-p ()
|
|
|
|
|
"Check if file is flagged for deletion in associated Dired buffer."
|
|
|
|
|
(image-dired-thumb-file-marked-p t))
|
2021-08-11 14:03:23 +02:00
|
|
|
|
|
2022-09-29 01:39:30 +02:00
|
|
|
|
(defun image-dired-do-flagged-delete ()
|
|
|
|
|
"Delete flagged thumbnails and associated images."
|
2022-08-20 22:44:14 +02:00
|
|
|
|
(interactive nil image-dired-thumbnail-mode)
|
|
|
|
|
(unless (derived-mode-p 'image-dired-thumbnail-mode)
|
|
|
|
|
(user-error "Not in `image-dired-thumbnail-mode'"))
|
2022-10-02 20:12:32 +02:00
|
|
|
|
(image-dired--with-dired-buffer
|
|
|
|
|
(dired-do-flagged-delete))
|
|
|
|
|
(let (deletions)
|
|
|
|
|
(save-excursion
|
|
|
|
|
(let ((inhibit-read-only t))
|
|
|
|
|
(goto-char (point-min))
|
|
|
|
|
(while (not (eobp))
|
|
|
|
|
(let ((file-name (image-dired-original-file-name)))
|
|
|
|
|
(if (image-dired--with-dired-buffer (dired-goto-file file-name))
|
|
|
|
|
(forward-char 2)
|
|
|
|
|
(delete-char 1)
|
|
|
|
|
(forward-char)
|
|
|
|
|
(setq deletions t))))))
|
|
|
|
|
(if deletions
|
|
|
|
|
(image-dired--line-up-with-method))))
|
2021-08-11 18:02:25 +02:00
|
|
|
|
|
2022-09-24 12:44:11 +02:00
|
|
|
|
(defun image-dired--thumb-update-mark-at-point ()
|
|
|
|
|
(with-silent-modifications
|
|
|
|
|
(cond ((image-dired-thumb-file-marked-p)
|
|
|
|
|
(add-face-text-property (point) (1+ (point))
|
|
|
|
|
'image-dired-thumb-mark))
|
|
|
|
|
((image-dired-thumb-file-flagged-p)
|
|
|
|
|
(add-face-text-property (point) (1+ (point))
|
|
|
|
|
'image-dired-thumb-flagged))
|
|
|
|
|
(t (remove-text-properties (point) (1+ (point))
|
|
|
|
|
'(face image-dired-thumb-mark))))))
|
|
|
|
|
|
|
|
|
|
(defun image-dired--thumb-update-marks ()
|
2022-09-29 01:25:10 +02:00
|
|
|
|
"Update the marks in the thumbnail buffer.
|
|
|
|
|
It's expected, that a thumbnail is always followed
|
|
|
|
|
by exactly one space or one newline character."
|
2021-08-11 14:03:23 +02:00
|
|
|
|
(when image-dired-thumb-visible-marks
|
|
|
|
|
(with-current-buffer image-dired-thumbnail-buffer
|
2021-08-13 12:25:27 +02:00
|
|
|
|
(save-mark-and-excursion
|
2021-08-11 14:03:23 +02:00
|
|
|
|
(goto-char (point-min))
|
|
|
|
|
(let ((inhibit-read-only t))
|
|
|
|
|
(while (not (eobp))
|
2022-09-24 12:44:11 +02:00
|
|
|
|
(image-dired--thumb-update-mark-at-point)
|
2022-09-24 11:49:46 +02:00
|
|
|
|
(forward-char 2)))))))
|
2021-08-11 14:03:23 +02:00
|
|
|
|
|
2021-08-11 13:39:53 +02:00
|
|
|
|
(defun image-dired-mouse-toggle-mark-1 ()
|
2021-10-27 04:53:41 +02:00
|
|
|
|
"Toggle Dired mark for current thumbnail.
|
|
|
|
|
Track this in associated Dired buffer if
|
|
|
|
|
`image-dired-track-movement' is non-nil."
|
2021-08-11 13:39:53 +02:00
|
|
|
|
(when image-dired-track-movement
|
|
|
|
|
(image-dired-track-original-file))
|
2022-09-15 22:19:00 +02:00
|
|
|
|
(image-dired--do-mark-command nil nil
|
2022-09-15 22:08:19 +02:00
|
|
|
|
(if (image-dired-dired-file-marked-p)
|
|
|
|
|
(dired-unmark 1)
|
|
|
|
|
(dired-mark 1))))
|
2021-08-11 13:39:53 +02:00
|
|
|
|
|
2007-04-22 13:44:05 +00:00
|
|
|
|
(defun image-dired-mouse-toggle-mark (event)
|
2021-10-27 04:53:41 +02:00
|
|
|
|
"Use mouse EVENT to toggle Dired mark for thumbnail.
|
2021-08-11 13:39:53 +02:00
|
|
|
|
Toggle marks of all thumbnails in region, if it's active.
|
2021-10-27 04:53:41 +02:00
|
|
|
|
Track this in associated Dired buffer if
|
|
|
|
|
`image-dired-track-movement' is non-nil."
|
2007-04-22 13:44:05 +00:00
|
|
|
|
(interactive "e")
|
2021-08-11 13:39:53 +02:00
|
|
|
|
(if (use-region-p)
|
|
|
|
|
(let ((end (region-end)))
|
|
|
|
|
(save-excursion
|
|
|
|
|
(goto-char (region-beginning))
|
|
|
|
|
(while (<= (point) end)
|
|
|
|
|
(when (image-dired-image-at-point-p)
|
|
|
|
|
(image-dired-mouse-toggle-mark-1))
|
|
|
|
|
(forward-char))))
|
|
|
|
|
(mouse-set-point event)
|
|
|
|
|
(goto-char (posn-point (event-end event)))
|
2021-08-11 14:03:23 +02:00
|
|
|
|
(image-dired-mouse-toggle-mark-1))
|
2022-09-24 12:44:11 +02:00
|
|
|
|
(image-dired--thumb-update-marks))
|
2007-04-22 13:44:05 +00:00
|
|
|
|
|
2021-10-27 06:05:39 +02:00
|
|
|
|
|
2021-11-08 06:42:44 +01:00
|
|
|
|
;;; bookmark.el support
|
2021-10-27 06:05:39 +02:00
|
|
|
|
|
|
|
|
|
(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.
|
2021-10-27 20:39:10 +02:00
|
|
|
|
(let ((image-dired-show-all-from-dir-max-files nil))
|
2021-10-27 06:05:39 +02:00
|
|
|
|
(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))))
|
|
|
|
|
|
2022-06-17 21:14:39 +02:00
|
|
|
|
(put 'image-dired-bookmark-jump 'bookmark-handler-type "Image-Dired")
|
2022-09-23 23:47:23 +02:00
|
|
|
|
|
2021-10-27 06:05:39 +02:00
|
|
|
|
|
2021-11-08 06:42:44 +01:00
|
|
|
|
;;; Obsolete
|
2021-10-23 06:49:09 +02:00
|
|
|
|
|
2021-10-27 05:16:05 +02:00
|
|
|
|
;;;###autoload
|
|
|
|
|
(define-obsolete-function-alias 'tumme #'image-dired "24.4")
|
|
|
|
|
|
|
|
|
|
;;;###autoload
|
|
|
|
|
(define-obsolete-function-alias 'image-dired-setup-dired-keybindings
|
|
|
|
|
#'image-dired-minor-mode "26.1")
|
|
|
|
|
|
2022-09-17 21:27:38 +02:00
|
|
|
|
(make-obsolete-variable 'image-dired-thumb-width
|
|
|
|
|
'image-dired-thumb-size "29.1")
|
|
|
|
|
(defcustom image-dired-thumb-width image-dired-thumb-size
|
|
|
|
|
"Width of thumbnails, in pixels."
|
2022-09-17 22:14:31 +02:00
|
|
|
|
:type 'natnum)
|
2022-09-17 21:27:38 +02:00
|
|
|
|
|
|
|
|
|
(make-obsolete-variable 'image-dired-thumb-height
|
|
|
|
|
'image-dired-thumb-size "29.1")
|
|
|
|
|
(defcustom image-dired-thumb-height image-dired-thumb-size
|
|
|
|
|
"Height of thumbnails, in pixels."
|
2022-09-17 22:14:31 +02:00
|
|
|
|
:type 'natnum)
|
2022-09-17 21:27:38 +02:00
|
|
|
|
|
2021-11-04 02:05:29 +01:00
|
|
|
|
(defcustom image-dired-temp-image-file
|
|
|
|
|
(expand-file-name ".image-dired_temp" image-dired-dir)
|
|
|
|
|
"Name of temporary image file used by various commands."
|
|
|
|
|
:type 'file)
|
|
|
|
|
(make-obsolete-variable 'image-dired-temp-image-file
|
|
|
|
|
"no longer used." "29.1")
|
|
|
|
|
|
|
|
|
|
(defcustom image-dired-cmd-create-temp-image-program
|
|
|
|
|
(if (executable-find "gm") "gm" "convert")
|
|
|
|
|
"Executable used to create temporary image.
|
|
|
|
|
Used together with `image-dired-cmd-create-temp-image-options'."
|
|
|
|
|
:type 'file
|
|
|
|
|
:version "29.1")
|
|
|
|
|
(make-obsolete-variable 'image-dired-cmd-create-temp-image-program
|
|
|
|
|
"no longer used." "29.1")
|
|
|
|
|
|
|
|
|
|
(defcustom image-dired-cmd-create-temp-image-options
|
|
|
|
|
(let ((opts '("-size" "%wx%h" "%f[0]"
|
|
|
|
|
"-resize" "%wx%h>"
|
|
|
|
|
"-strip" "jpeg:%t")))
|
|
|
|
|
(if (executable-find "gm") (cons "convert" opts) opts))
|
|
|
|
|
"Options of command used to create temporary image for display window.
|
|
|
|
|
Used together with `image-dired-cmd-create-temp-image-program',
|
|
|
|
|
Available format specifiers are: %w and %h which are replaced by
|
|
|
|
|
the calculated max size for width and height in the image display window,
|
|
|
|
|
%f which is replaced by the file name of the original image and %t which
|
|
|
|
|
is replaced by the file name of the temporary file."
|
|
|
|
|
:version "29.1"
|
|
|
|
|
:type '(repeat (string :tag "Argument")))
|
|
|
|
|
(make-obsolete-variable 'image-dired-cmd-create-temp-image-options
|
|
|
|
|
"no longer used." "29.1")
|
|
|
|
|
|
|
|
|
|
(defcustom image-dired-display-window-width-correction 1
|
|
|
|
|
"Number to be used to correct image display window width.
|
|
|
|
|
Change if the default (1) does not work (i.e. if the image does not
|
|
|
|
|
completely fit)."
|
|
|
|
|
:type 'integer)
|
|
|
|
|
(make-obsolete-variable 'image-dired-display-window-width-correction
|
|
|
|
|
"no longer used." "29.1")
|
|
|
|
|
|
|
|
|
|
(defcustom image-dired-display-window-height-correction 0
|
|
|
|
|
"Number to be used to correct image display window height.
|
|
|
|
|
Change if the default (0) does not work (i.e. if the image does not
|
|
|
|
|
completely fit)."
|
|
|
|
|
:type 'integer)
|
|
|
|
|
(make-obsolete-variable 'image-dired-display-window-height-correction
|
|
|
|
|
"no longer used." "29.1")
|
|
|
|
|
|
2022-09-15 22:08:19 +02:00
|
|
|
|
(defun image-dired-toggle-mark-thumb-original-file ()
|
|
|
|
|
"Toggle mark on original image file in associated Dired buffer."
|
|
|
|
|
(declare (obsolete nil "29.1"))
|
2022-10-04 17:36:09 +02:00
|
|
|
|
(interactive nil image-dired-thumbnail-mode image-dired-image-mode)
|
2022-09-15 22:19:00 +02:00
|
|
|
|
(image-dired--do-mark-command nil t
|
2022-09-15 22:08:19 +02:00
|
|
|
|
(if (image-dired-dired-file-marked-p)
|
|
|
|
|
(dired-unmark 1)
|
|
|
|
|
(dired-mark 1))))
|
|
|
|
|
|
2021-11-04 02:05:29 +01:00
|
|
|
|
(defun image-dired-display-window-width (window)
|
|
|
|
|
"Return width, in pixels, of WINDOW."
|
|
|
|
|
(declare (obsolete nil "29.1"))
|
2022-08-31 05:52:11 +02:00
|
|
|
|
(- (window-body-width window t)
|
2021-11-04 02:05:29 +01:00
|
|
|
|
image-dired-display-window-width-correction))
|
|
|
|
|
|
|
|
|
|
(defun image-dired-display-window-height (window)
|
|
|
|
|
"Return height, in pixels, of WINDOW."
|
|
|
|
|
(declare (obsolete nil "29.1"))
|
|
|
|
|
(- (image-dired-window-height-pixels window)
|
|
|
|
|
image-dired-display-window-height-correction))
|
|
|
|
|
|
|
|
|
|
(defun image-dired-window-height-pixels (window)
|
|
|
|
|
"Calculate WINDOW height in pixels."
|
|
|
|
|
(declare (obsolete nil "29.1"))
|
|
|
|
|
;; Note: The mode-line consumes one line
|
2022-08-23 14:59:47 +02:00
|
|
|
|
(* (- (window-height window) 1) (frame-char-height)))
|
2021-11-04 02:05:29 +01:00
|
|
|
|
|
2021-10-23 06:49:09 +02:00
|
|
|
|
(defcustom image-dired-cmd-read-exif-data-program "exiftool"
|
|
|
|
|
"Program used to read EXIF data to image.
|
|
|
|
|
Used together with `image-dired-cmd-read-exif-data-options'."
|
|
|
|
|
:type 'file)
|
|
|
|
|
(make-obsolete-variable 'image-dired-cmd-read-exif-data-program
|
|
|
|
|
"use `exif-parse-file' and `exif-field' instead." "29.1")
|
|
|
|
|
|
|
|
|
|
(defcustom image-dired-cmd-read-exif-data-options '("-s" "-s" "-s" "-%t" "%f")
|
|
|
|
|
"Arguments of command used to read EXIF data.
|
|
|
|
|
Used with `image-dired-cmd-read-exif-data-program'.
|
|
|
|
|
Available format specifiers are: %f which is replaced
|
|
|
|
|
by the image file name and %t which is replaced by the tag name."
|
|
|
|
|
:version "26.1"
|
|
|
|
|
:type '(repeat (string :tag "Argument")))
|
|
|
|
|
(make-obsolete-variable 'image-dired-cmd-read-exif-data-options
|
|
|
|
|
"use `exif-parse-file' and `exif-field' instead." "29.1")
|
|
|
|
|
|
|
|
|
|
(defun image-dired-get-exif-data (file tag-name)
|
|
|
|
|
"From FILE, return EXIF tag TAG-NAME."
|
|
|
|
|
(declare (obsolete "use `exif-parse-file' and `exif-field' instead." "29.1"))
|
|
|
|
|
(image-dired--check-executable-exists
|
|
|
|
|
'image-dired-cmd-read-exif-data-program)
|
|
|
|
|
(let ((buf (get-buffer-create "*image-dired-get-exif-data*"))
|
|
|
|
|
(spec (list (cons ?f file) (cons ?t tag-name)))
|
|
|
|
|
tag-value)
|
|
|
|
|
(with-current-buffer buf
|
|
|
|
|
(delete-region (point-min) (point-max))
|
|
|
|
|
(if (not (eq (apply #'call-process image-dired-cmd-read-exif-data-program
|
|
|
|
|
nil t nil
|
|
|
|
|
(mapcar
|
|
|
|
|
(lambda (arg) (format-spec arg spec))
|
|
|
|
|
image-dired-cmd-read-exif-data-options))
|
|
|
|
|
0))
|
|
|
|
|
(error "Could not get EXIF tag")
|
|
|
|
|
(goto-char (point-min))
|
|
|
|
|
;; Clean buffer from newlines and carriage returns before
|
|
|
|
|
;; getting final info
|
|
|
|
|
(while (search-forward-regexp "[\n\r]" nil t)
|
|
|
|
|
(replace-match "" nil t))
|
|
|
|
|
(setq tag-value (buffer-substring (point-min) (point-max)))))
|
|
|
|
|
tag-value))
|
|
|
|
|
|
2021-10-28 01:59:01 +02:00
|
|
|
|
(defcustom image-dired-cmd-rotate-thumbnail-program
|
|
|
|
|
(if (executable-find "gm") "gm" "mogrify")
|
|
|
|
|
"Executable used to rotate thumbnail.
|
|
|
|
|
Used together with `image-dired-cmd-rotate-thumbnail-options'."
|
|
|
|
|
:type 'file
|
|
|
|
|
:version "29.1")
|
|
|
|
|
(make-obsolete-variable 'image-dired-cmd-rotate-thumbnail-program nil "29.1")
|
|
|
|
|
|
|
|
|
|
(defcustom image-dired-cmd-rotate-thumbnail-options
|
|
|
|
|
(let ((opts '("-rotate" "%d" "%t")))
|
|
|
|
|
(if (executable-find "gm") (cons "mogrify" opts) opts))
|
|
|
|
|
"Arguments of command used to rotate thumbnail image.
|
|
|
|
|
Used with `image-dired-cmd-rotate-thumbnail-program'.
|
|
|
|
|
Available format specifiers are: %d which is replaced by the
|
|
|
|
|
number of (positive) degrees to rotate the image, normally 90 or 270
|
|
|
|
|
\(for 90 degrees right and left), %t which is replaced by the file name
|
|
|
|
|
of the thumbnail file."
|
|
|
|
|
:version "29.1"
|
|
|
|
|
:type '(repeat (string :tag "Argument")))
|
|
|
|
|
(make-obsolete-variable 'image-dired-cmd-rotate-thumbnail-options nil "29.1")
|
|
|
|
|
|
2022-09-09 18:09:36 +02:00
|
|
|
|
(declare-function clear-image-cache "image.c" (&optional filter))
|
|
|
|
|
|
2021-10-28 01:59:01 +02:00
|
|
|
|
(defun image-dired-rotate-thumbnail (degrees)
|
|
|
|
|
"Rotate thumbnail DEGREES degrees."
|
|
|
|
|
(declare (obsolete image-dired-refresh-thumb "29.1"))
|
|
|
|
|
(image-dired--check-executable-exists
|
|
|
|
|
'image-dired-cmd-rotate-thumbnail-program)
|
|
|
|
|
(if (not (image-dired-image-at-point-p))
|
|
|
|
|
(message "No thumbnail at point")
|
|
|
|
|
(let* ((file (image-dired-thumb-name (image-dired-original-file-name)))
|
|
|
|
|
(thumb (expand-file-name file))
|
|
|
|
|
(spec (list (cons ?d degrees) (cons ?t thumb))))
|
|
|
|
|
(apply #'call-process image-dired-cmd-rotate-thumbnail-program nil nil nil
|
|
|
|
|
(mapcar (lambda (arg) (format-spec arg spec))
|
|
|
|
|
image-dired-cmd-rotate-thumbnail-options))
|
|
|
|
|
(clear-image-cache thumb))))
|
|
|
|
|
|
|
|
|
|
(defun image-dired-rotate-thumbnail-left ()
|
|
|
|
|
"Rotate thumbnail left (counter clockwise) 90 degrees."
|
|
|
|
|
(declare (obsolete image-dired-refresh-thumb "29.1"))
|
2022-08-20 22:44:14 +02:00
|
|
|
|
(interactive nil image-dired-thumbnail-mode)
|
2021-10-28 01:59:01 +02:00
|
|
|
|
(with-suppressed-warnings ((obsolete image-dired-rotate-thumbnail))
|
|
|
|
|
(image-dired-rotate-thumbnail "270")))
|
|
|
|
|
|
|
|
|
|
(defun image-dired-rotate-thumbnail-right ()
|
|
|
|
|
"Rotate thumbnail counter right (clockwise) 90 degrees."
|
|
|
|
|
(declare (obsolete image-dired-refresh-thumb "29.1"))
|
2022-08-20 22:44:14 +02:00
|
|
|
|
(interactive nil image-dired-thumbnail-mode)
|
2021-10-28 01:59:01 +02:00
|
|
|
|
(with-suppressed-warnings ((obsolete image-dired-rotate-thumbnail))
|
|
|
|
|
(image-dired-rotate-thumbnail "90")))
|
|
|
|
|
|
2021-11-03 07:02:13 +01:00
|
|
|
|
(defun image-dired-modify-mark-on-thumb-original-file (command)
|
|
|
|
|
"Modify mark in Dired buffer.
|
|
|
|
|
COMMAND is one of `mark' for marking file in Dired, `unmark' for
|
|
|
|
|
unmarking file in Dired or `flag' for flagging file for delete in
|
|
|
|
|
Dired."
|
|
|
|
|
(declare (obsolete image-dired--on-file-in-dired-buffer "29.1"))
|
|
|
|
|
(let ((file-name (image-dired-original-file-name))
|
|
|
|
|
(dired-buf (image-dired-associated-dired-buffer)))
|
|
|
|
|
(if (not (and dired-buf file-name))
|
2022-07-21 21:07:54 +02:00
|
|
|
|
(message "No image, or image with correct properties, at point")
|
2022-08-23 14:59:47 +02:00
|
|
|
|
(with-current-buffer dired-buf
|
2021-11-03 07:02:13 +01:00
|
|
|
|
(message "%s" file-name)
|
|
|
|
|
(when (dired-goto-file file-name)
|
|
|
|
|
(cond ((eq command 'mark) (dired-mark 1))
|
|
|
|
|
((eq command 'unmark) (dired-unmark 1))
|
|
|
|
|
((eq command 'toggle)
|
|
|
|
|
(if (image-dired-dired-file-marked-p)
|
|
|
|
|
(dired-unmark 1)
|
|
|
|
|
(dired-mark 1)))
|
|
|
|
|
((eq command 'flag) (dired-flag-file-deletion 1)))
|
2022-09-24 12:44:11 +02:00
|
|
|
|
(image-dired--thumb-update-marks))))))
|
2021-11-03 07:02:13 +01:00
|
|
|
|
|
2021-11-04 02:05:29 +01:00
|
|
|
|
(defun image-dired-display-current-image-full ()
|
|
|
|
|
"Display current image in full size."
|
2022-09-14 15:34:38 +02:00
|
|
|
|
(declare (obsolete image-transform-reset-to-original "29.1"))
|
2021-11-04 02:05:29 +01:00
|
|
|
|
(interactive nil image-dired-thumbnail-mode)
|
|
|
|
|
(let ((file (image-dired-original-file-name)))
|
|
|
|
|
(if file
|
|
|
|
|
(progn
|
|
|
|
|
(image-dired-display-image file)
|
|
|
|
|
(with-current-buffer image-dired-display-image-buffer
|
2022-09-14 15:34:38 +02:00
|
|
|
|
(image-transform-reset-to-original)))
|
2021-11-04 02:05:29 +01:00
|
|
|
|
(error "No original file name at point"))))
|
|
|
|
|
|
|
|
|
|
(defun image-dired-display-current-image-sized ()
|
|
|
|
|
"Display current image in sized to fit window dimensions."
|
|
|
|
|
(declare (obsolete image-mode-fit-frame "29.1"))
|
|
|
|
|
(interactive nil image-dired-thumbnail-mode)
|
|
|
|
|
(let ((file (image-dired-original-file-name)))
|
|
|
|
|
(if file
|
|
|
|
|
(progn
|
|
|
|
|
(image-dired-display-image file))
|
|
|
|
|
(error "No original file name at point"))))
|
|
|
|
|
|
2022-08-23 14:46:03 +02:00
|
|
|
|
(make-obsolete-variable 'image-dired-tag-file-list nil "29.1")
|
|
|
|
|
(defvar image-dired-tag-file-list nil
|
|
|
|
|
"List to store tag-file structure.")
|
|
|
|
|
|
2021-11-05 00:47:00 +01:00
|
|
|
|
(defun image-dired-add-to-tag-file-list (tag file)
|
|
|
|
|
"Add relation between TAG and FILE."
|
|
|
|
|
(declare (obsolete nil "29.1"))
|
|
|
|
|
(let (curr)
|
|
|
|
|
(if image-dired-tag-file-list
|
|
|
|
|
(if (setq curr (assoc tag image-dired-tag-file-list))
|
|
|
|
|
(if (not (member file curr))
|
|
|
|
|
(setcdr curr (cons file (cdr curr))))
|
|
|
|
|
(setcdr image-dired-tag-file-list
|
|
|
|
|
(cons (list tag file) (cdr image-dired-tag-file-list))))
|
|
|
|
|
(setq image-dired-tag-file-list (list (list tag file))))))
|
|
|
|
|
|
2021-11-12 04:10:40 +01:00
|
|
|
|
(defvar image-dired-slideshow-count 0
|
|
|
|
|
"Keeping track on number of images in slideshow.")
|
|
|
|
|
(make-obsolete-variable 'image-dired-slideshow-count "no longer used." "29.1")
|
|
|
|
|
|
|
|
|
|
(defvar image-dired-slideshow-times 0
|
|
|
|
|
"Number of pictures to display in slideshow.")
|
|
|
|
|
(make-obsolete-variable 'image-dired-slideshow-times "no longer used." "29.1")
|
|
|
|
|
|
2022-08-23 14:46:03 +02:00
|
|
|
|
(make-obsolete-variable 'image-dired-gallery-dir nil "29.1")
|
|
|
|
|
(defcustom image-dired-gallery-dir
|
|
|
|
|
(expand-file-name ".image-dired_gallery" image-dired-dir)
|
|
|
|
|
"Directory to store generated gallery html pages.
|
|
|
|
|
The name of this directory needs to be \"shared\" to the public
|
|
|
|
|
so that it can access the index.html page that image-dired creates."
|
|
|
|
|
:type 'directory)
|
|
|
|
|
|
|
|
|
|
(make-obsolete-variable 'image-dired-gallery-image-root-url nil "29.1")
|
|
|
|
|
(defcustom image-dired-gallery-image-root-url
|
|
|
|
|
"https://example.org/image-diredpics"
|
|
|
|
|
"URL where the full size images are to be found on your web server.
|
|
|
|
|
Note that this URL has to be configured on your web server.
|
|
|
|
|
Image-Dired expects to find pictures in this directory.
|
|
|
|
|
This is used by `image-dired-gallery-generate'."
|
|
|
|
|
:type 'string
|
|
|
|
|
:version "29.1")
|
|
|
|
|
|
|
|
|
|
(make-obsolete-variable 'image-dired-gallery-thumb-image-root-url nil "29.1")
|
|
|
|
|
(defcustom image-dired-gallery-thumb-image-root-url
|
|
|
|
|
"https://example.org/image-diredthumbs"
|
|
|
|
|
"URL where the thumbnail images are to be found on your web server.
|
|
|
|
|
Note that URL path has to be configured on your web server.
|
|
|
|
|
Image-Dired expects to find pictures in this directory.
|
|
|
|
|
This is used by `image-dired-gallery-generate'."
|
|
|
|
|
:type 'string
|
|
|
|
|
:version "29.1")
|
|
|
|
|
|
|
|
|
|
(make-obsolete-variable 'image-dired-gallery-hidden-tags nil "29.1")
|
|
|
|
|
(defcustom image-dired-gallery-hidden-tags
|
|
|
|
|
(list "private" "hidden" "pending")
|
|
|
|
|
"List of \"hidden\" tags.
|
|
|
|
|
Used by `image-dired-gallery-generate' to leave out \"hidden\" images."
|
|
|
|
|
:type '(repeat string))
|
|
|
|
|
|
|
|
|
|
(make-obsolete-variable 'image-dired-file-tag-list nil "29.1")
|
|
|
|
|
(defvar image-dired-file-tag-list nil
|
|
|
|
|
"List to store file-tag structure.")
|
|
|
|
|
|
|
|
|
|
(make-obsolete-variable 'image-dired-file-comment-list nil "29.1")
|
|
|
|
|
(defvar image-dired-file-comment-list nil
|
|
|
|
|
"List to store file comments.")
|
|
|
|
|
|
|
|
|
|
(defun image-dired--add-to-tag-file-lists (tag file)
|
|
|
|
|
"Helper function used from `image-dired--create-gallery-lists'.
|
|
|
|
|
|
|
|
|
|
Add TAG to FILE in one list and FILE to TAG in the other.
|
|
|
|
|
|
|
|
|
|
Lisp structures look like the following:
|
|
|
|
|
|
|
|
|
|
image-dired-file-tag-list:
|
|
|
|
|
|
|
|
|
|
((\"filename1\" \"tag1\" \"tag2\" \"tag3\" ...)
|
|
|
|
|
(\"filename2\" \"tag1\" \"tag2\" \"tag3\" ...)
|
|
|
|
|
...)
|
|
|
|
|
|
|
|
|
|
image-dired-tag-file-list:
|
|
|
|
|
|
|
|
|
|
((\"tag1\" \"filename1\" \"filename2\" \"filename3\" ...)
|
|
|
|
|
(\"tag2\" \"filename1\" \"filename2\" \"filename3\" ...)
|
|
|
|
|
...)"
|
|
|
|
|
(declare (obsolete nil "29.1"))
|
|
|
|
|
;; Add tag to file list
|
|
|
|
|
(let (curr)
|
|
|
|
|
(if image-dired-file-tag-list
|
|
|
|
|
(if (setq curr (assoc file image-dired-file-tag-list))
|
|
|
|
|
(setcdr curr (cons tag (cdr curr)))
|
|
|
|
|
(setcdr image-dired-file-tag-list
|
|
|
|
|
(cons (list file tag) (cdr image-dired-file-tag-list))))
|
|
|
|
|
(setq image-dired-file-tag-list (list (list file tag))))
|
|
|
|
|
;; Add file to tag list
|
|
|
|
|
(if image-dired-tag-file-list
|
|
|
|
|
(if (setq curr (assoc tag image-dired-tag-file-list))
|
|
|
|
|
(if (not (member file curr))
|
|
|
|
|
(setcdr curr (cons file (cdr curr))))
|
|
|
|
|
(setcdr image-dired-tag-file-list
|
|
|
|
|
(cons (list tag file) (cdr image-dired-tag-file-list))))
|
|
|
|
|
(setq image-dired-tag-file-list (list (list tag file))))))
|
|
|
|
|
|
|
|
|
|
(defun image-dired--add-to-file-comment-list (file comment)
|
|
|
|
|
"Helper function used from `image-dired--create-gallery-lists'.
|
|
|
|
|
|
|
|
|
|
For FILE, add COMMENT to list.
|
|
|
|
|
|
|
|
|
|
Lisp structure looks like the following:
|
|
|
|
|
|
|
|
|
|
image-dired-file-comment-list:
|
|
|
|
|
|
|
|
|
|
((\"filename1\" . \"comment1\")
|
|
|
|
|
(\"filename2\" . \"comment2\")
|
|
|
|
|
...)"
|
|
|
|
|
(declare (obsolete nil "29.1"))
|
|
|
|
|
(if image-dired-file-comment-list
|
|
|
|
|
(if (not (assoc file image-dired-file-comment-list))
|
|
|
|
|
(setcdr image-dired-file-comment-list
|
|
|
|
|
(cons (cons file comment)
|
|
|
|
|
(cdr image-dired-file-comment-list))))
|
|
|
|
|
(setq image-dired-file-comment-list (list (cons file comment)))))
|
|
|
|
|
|
|
|
|
|
(defun image-dired--create-gallery-lists ()
|
|
|
|
|
"Create temporary lists used by `image-dired-gallery-generate'."
|
|
|
|
|
(declare (obsolete nil "29.1"))
|
|
|
|
|
(image-dired-sane-db-file)
|
|
|
|
|
(image-dired--with-db-file
|
|
|
|
|
(let (end beg file row-tags)
|
|
|
|
|
(setq image-dired-tag-file-list nil)
|
|
|
|
|
(setq image-dired-file-tag-list nil)
|
|
|
|
|
(setq image-dired-file-comment-list nil)
|
|
|
|
|
(goto-char (point-min))
|
|
|
|
|
(while (search-forward-regexp "^." nil t)
|
|
|
|
|
(end-of-line)
|
|
|
|
|
(setq end (point))
|
|
|
|
|
(beginning-of-line)
|
|
|
|
|
(setq beg (point))
|
|
|
|
|
(unless (search-forward ";" end nil)
|
|
|
|
|
(error "Something is really wrong, check format of database"))
|
|
|
|
|
(setq row-tags (split-string
|
|
|
|
|
(buffer-substring beg end) ";"))
|
|
|
|
|
(setq file (car row-tags))
|
|
|
|
|
(dolist (x (cdr row-tags))
|
|
|
|
|
(with-suppressed-warnings
|
|
|
|
|
((obsolete image-dired--add-to-tag-file-lists
|
|
|
|
|
image-dired--add-to-file-comment-list))
|
|
|
|
|
(if (not (string-match "^comment:\\(.*\\)" x))
|
|
|
|
|
(image-dired--add-to-tag-file-lists x file)
|
|
|
|
|
(image-dired--add-to-file-comment-list file (match-string 1 x))))))))
|
|
|
|
|
;; Sort tag-file list
|
|
|
|
|
(setq image-dired-tag-file-list
|
|
|
|
|
(sort image-dired-tag-file-list
|
|
|
|
|
(lambda (x y)
|
|
|
|
|
(string< (car x) (car y))))))
|
|
|
|
|
|
|
|
|
|
(defun image-dired--hidden-p (file)
|
|
|
|
|
"Return t if image FILE has a \"hidden\" tag."
|
|
|
|
|
(declare (obsolete nil "29.1"))
|
|
|
|
|
(cl-loop for tag in (cdr (assoc file image-dired-file-tag-list))
|
|
|
|
|
if (member tag image-dired-gallery-hidden-tags) return t))
|
|
|
|
|
|
|
|
|
|
(defun image-dired-gallery-generate ()
|
|
|
|
|
"Generate gallery pages.
|
|
|
|
|
First we create a couple of Lisp structures from the database to make
|
|
|
|
|
it easier to generate, then HTML-files are created in
|
|
|
|
|
`image-dired-gallery-dir'."
|
|
|
|
|
(declare (obsolete nil "29.1"))
|
|
|
|
|
(interactive)
|
|
|
|
|
(if (eq 'per-directory image-dired-thumbnail-storage)
|
|
|
|
|
(error "Currently, gallery generation is not supported \
|
|
|
|
|
when using per-directory thumbnail file storage"))
|
|
|
|
|
(with-suppressed-warnings ((obsolete image-dired--create-gallery-lists))
|
|
|
|
|
(image-dired--create-gallery-lists))
|
|
|
|
|
(let ((tags image-dired-tag-file-list)
|
|
|
|
|
(index-file (format "%s/index.html" image-dired-gallery-dir))
|
|
|
|
|
count tag tag-file
|
|
|
|
|
comment file-tags tag-link tag-link-list)
|
|
|
|
|
;; Make sure gallery root exist
|
|
|
|
|
(if (file-exists-p image-dired-gallery-dir)
|
|
|
|
|
(if (not (file-directory-p image-dired-gallery-dir))
|
|
|
|
|
(error "Variable image-dired-gallery-dir is not a directory"))
|
|
|
|
|
;; FIXME: Should we set umask to 077 here, as we do for thumbnails?
|
|
|
|
|
(make-directory image-dired-gallery-dir))
|
|
|
|
|
;; Open index file
|
|
|
|
|
(with-temp-file index-file
|
|
|
|
|
(if (file-exists-p index-file)
|
|
|
|
|
(insert-file-contents index-file))
|
|
|
|
|
(insert "<html>\n")
|
|
|
|
|
(insert " <body>\n")
|
|
|
|
|
(insert " <h2>Image-Dired Gallery</h2>\n")
|
|
|
|
|
(insert (format "<p>\n Gallery generated %s\n <p>\n"
|
|
|
|
|
(current-time-string)))
|
|
|
|
|
(insert " <h3>Tag index</h3>\n")
|
|
|
|
|
(setq count 1)
|
|
|
|
|
;; Pre-generate list of all tag links
|
|
|
|
|
(dolist (curr tags)
|
|
|
|
|
(setq tag (car curr))
|
|
|
|
|
(when (not (member tag image-dired-gallery-hidden-tags))
|
|
|
|
|
(setq tag-link (format "<a href=\"%d.html\">%s</a>" count tag))
|
|
|
|
|
(if tag-link-list
|
|
|
|
|
(setq tag-link-list
|
|
|
|
|
(append tag-link-list (list (cons tag tag-link))))
|
|
|
|
|
(setq tag-link-list (list (cons tag tag-link))))
|
|
|
|
|
(setq count (1+ count))))
|
|
|
|
|
(setq count 1)
|
|
|
|
|
;; Main loop where we generated thumbnail pages per tag
|
|
|
|
|
(dolist (curr tags)
|
|
|
|
|
(setq tag (car curr))
|
|
|
|
|
;; Don't display hidden tags
|
|
|
|
|
(when (not (member tag image-dired-gallery-hidden-tags))
|
|
|
|
|
;; Insert link to tag page in index
|
|
|
|
|
(insert (format " %s<br>\n" (cdr (assoc tag tag-link-list))))
|
|
|
|
|
;; Open per-tag file
|
|
|
|
|
(setq tag-file (format "%s/%s.html" image-dired-gallery-dir count))
|
|
|
|
|
(with-temp-file tag-file
|
|
|
|
|
(if (file-exists-p tag-file)
|
|
|
|
|
(insert-file-contents tag-file))
|
|
|
|
|
(erase-buffer)
|
|
|
|
|
(insert "<html>\n")
|
|
|
|
|
(insert " <body>\n")
|
|
|
|
|
(insert " <p><a href=\"index.html\">Index</a></p>\n")
|
|
|
|
|
(insert (format " <h2>Images with tag "%s"</h2>" tag))
|
|
|
|
|
;; Main loop for files per tag page
|
|
|
|
|
(dolist (file (cdr curr))
|
|
|
|
|
(unless (image-dired-hidden-p file)
|
|
|
|
|
;; Insert thumbnail with link to full image
|
|
|
|
|
(insert
|
|
|
|
|
(format "<a href=\"%s/%s\"><img src=\"%s/%s\"%s></a>\n"
|
|
|
|
|
image-dired-gallery-image-root-url
|
|
|
|
|
(file-name-nondirectory file)
|
|
|
|
|
image-dired-gallery-thumb-image-root-url
|
|
|
|
|
(file-name-nondirectory (image-dired-thumb-name file)) file))
|
|
|
|
|
;; Insert comment, if any
|
|
|
|
|
(if (setq comment (cdr (assoc file image-dired-file-comment-list)))
|
|
|
|
|
(insert (format "<br>\n%s<br>\n" comment))
|
|
|
|
|
(insert "<br>\n"))
|
|
|
|
|
;; Insert links to other tags, if any
|
|
|
|
|
(when (> (length
|
|
|
|
|
(setq file-tags (assoc file image-dired-file-tag-list))) 2)
|
|
|
|
|
(insert "[ ")
|
|
|
|
|
(dolist (extra-tag file-tags)
|
|
|
|
|
;; Only insert if not file name or the main tag
|
|
|
|
|
(if (and (not (equal extra-tag tag))
|
|
|
|
|
(not (equal extra-tag file)))
|
|
|
|
|
(insert
|
|
|
|
|
(format "%s " (cdr (assoc extra-tag tag-link-list))))))
|
|
|
|
|
(insert "]<br>\n"))))
|
|
|
|
|
(insert " <p><a href=\"index.html\">Index</a></p>\n")
|
|
|
|
|
(insert " </body>\n")
|
|
|
|
|
(insert "</html>\n"))
|
|
|
|
|
(setq count (1+ count))))
|
|
|
|
|
(insert " </body>\n")
|
|
|
|
|
(insert "</html>"))))
|
|
|
|
|
|
2022-09-23 20:18:17 +02:00
|
|
|
|
(define-obsolete-function-alias 'image-dired-slideshow-step #'image-dired--slideshow-step "29.1")
|
|
|
|
|
(define-obsolete-function-alias 'image-dired-slideshow-stop #'image-dired--slideshow-stop "29.1")
|
2021-11-04 02:05:29 +01:00
|
|
|
|
(define-obsolete-function-alias 'image-dired-create-display-image-buffer
|
|
|
|
|
#'ignore "29.1")
|
2022-09-24 13:08:11 +02:00
|
|
|
|
;; These can't use the #' quote as they point to obsolete names.
|
2021-11-05 00:47:00 +01:00
|
|
|
|
(define-obsolete-function-alias 'image-dired-create-gallery-lists
|
2022-08-23 14:46:03 +02:00
|
|
|
|
'image-dired--create-gallery-lists "29.1")
|
2021-11-05 00:47:00 +01:00
|
|
|
|
(define-obsolete-function-alias 'image-dired-add-to-file-comment-list
|
2022-08-23 14:46:03 +02:00
|
|
|
|
'image-dired--add-to-file-comment-list "29.1")
|
2021-11-05 00:47:00 +01:00
|
|
|
|
(define-obsolete-function-alias 'image-dired-add-to-tag-file-lists
|
2022-08-23 14:46:03 +02:00
|
|
|
|
'image-dired--add-to-tag-file-lists "29.1")
|
2021-11-05 00:47:00 +01:00
|
|
|
|
(define-obsolete-function-alias 'image-dired-hidden-p
|
2022-08-23 14:46:03 +02:00
|
|
|
|
'image-dired--hidden-p "29.1")
|
2022-09-24 12:44:11 +02:00
|
|
|
|
(define-obsolete-function-alias 'image-dired-thumb-update-marks
|
|
|
|
|
#'image-dired--thumb-update-marks "29.1")
|
2022-09-24 13:08:11 +02:00
|
|
|
|
(define-obsolete-function-alias 'image-dired-get-thumbnail-image
|
|
|
|
|
#'image-dired--get-create-thumbnail-file "29.1")
|
2022-09-24 10:45:37 +02:00
|
|
|
|
(define-obsolete-function-alias 'image-dired-display-thumb-properties
|
|
|
|
|
#'image-dired--update-header-line "29.1")
|
2022-09-29 01:39:30 +02:00
|
|
|
|
(define-obsolete-function-alias 'image-dired-delete-marked
|
|
|
|
|
#'image-dired-do-flagged-delete "29.1")
|
2022-10-04 17:36:09 +02:00
|
|
|
|
(define-obsolete-function-alias 'image-dired-display-image-mode
|
|
|
|
|
#'image-dired-image-mode "29.1")
|
|
|
|
|
(define-obsolete-function-alias 'image-dired-display-thumbnail-original-image
|
|
|
|
|
#'image-dired-display-this "29.1")
|
|
|
|
|
(define-obsolete-function-alias 'image-dired-display-next-thumbnail-original
|
|
|
|
|
#'image-dired-display-next "29.1")
|
|
|
|
|
(define-obsolete-function-alias 'image-dired-display-previous-thumbnail-original
|
|
|
|
|
#'image-dired-display-previous "29.1")
|
2021-11-04 02:05:29 +01:00
|
|
|
|
|
2007-04-22 13:44:05 +00:00
|
|
|
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
|
|
|
;;;;;;;;; TEST-SECTION ;;;;;;;;;;;
|
|
|
|
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
|
|
|
|
|
|
|
|
;; (defvar image-dired-dir-max-size 12300000)
|
|
|
|
|
|
|
|
|
|
;; (defun image-dired-test-clean-old-files ()
|
|
|
|
|
;; "Clean `image-dired-dir' from old thumbnail files.
|
|
|
|
|
;; \"Oldness\" measured using last access time. If the total size of all
|
|
|
|
|
;; thumbnail files in `image-dired-dir' is larger than 'image-dired-dir-max-size',
|
|
|
|
|
;; old files are deleted until the max size is reached."
|
|
|
|
|
;; (let* ((files
|
|
|
|
|
;; (sort
|
|
|
|
|
;; (mapcar
|
|
|
|
|
;; (lambda (f)
|
|
|
|
|
;; (let ((fattribs (file-attributes f)))
|
file-attributes cleanup
Mostly, this replaces magic-number calls like (nth 4 A) with
more-informative calls like (file-attribute-access-time A).
It also fixes some documentation and minor timestamp coding
issues that I noticed while looking into this.
* doc/lispref/files.texi (File Attributes):
* lisp/files.el (file-attribute-size)
(file-attribute-inode-number, file-attribute-device-number):
* src/dired.c (Fdirectory_files_and_attributes)
(Ffile_attributes):
Mention which attributes must be integers, or nonnegative integers,
as opposed to merely being numbers. Remove no-longer-correct
talk about representing large integers as conses of integers.
* doc/lispref/files.texi (Magic File Names):
* doc/misc/gnus.texi (Low-level interface to the spam-stat dictionary):
* lisp/autorevert.el (auto-revert-find-file-function)
(auto-revert-tail-mode, auto-revert-handler):
* lisp/auth-source.el (auth-source-netrc-parse):
* lisp/cedet/ede/files.el (ede--inode-for-dir):
* lisp/cedet/semantic/db-file.el (object-write):
* lisp/cedet/semantic/db-mode.el (semanticdb-kill-hook):
* lisp/cedet/semantic/db.el (semanticdb-needs-refresh-p)
(semanticdb-synchronize):
* lisp/cedet/srecode/table.el (srecode-mode-table-new):
* lisp/desktop.el (desktop-save, desktop-read):
* lisp/dired-aux.el (dired-file-set-difference)
(dired-do-chxxx, dired-do-chmod, dired-copy-file-recursive)
(dired-create-files):
* lisp/dired.el (dired-directory-changed-p, dired-readin):
* lisp/dos-w32.el (w32-direct-print-region-helper):
* lisp/emacs-lisp/autoload.el (autoload-generate-file-autoloads)
(autoload-find-destination, update-directory-autoloads):
* lisp/emacs-lisp/shadow.el (load-path-shadows-same-file-or-nonexistent):
* lisp/epg.el (epg--start, epg-wait-for-completion):
* lisp/eshell/em-ls.el (eshell-ls-filetype-p)
(eshell-ls-applicable, eshell-ls-size-string)
(eshell-ls-file, eshell-ls-dir, eshell-ls-files)
(eshell-ls-entries):
* lisp/eshell/em-pred.el (eshell-predicate-alist)
(eshell-pred-file-type, eshell-pred-file-links)
(eshell-pred-file-size):
* lisp/eshell/em-unix.el (eshell-shuffle-files, eshell/cat)
(eshell-du-sum-directory, eshell/du):
* lisp/eshell/esh-util.el (eshell-read-passwd)
(eshell-read-hosts):
* lisp/files.el (remote-file-name-inhibit-cache)
(find-file-noselect, insert-file-1, dir-locals-find-file)
(dir-locals-read-from-dir, backup-buffer)
(file-ownership-preserved-p, copy-directory)
(read-file-modes):
* lisp/find-lisp.el (find-lisp-format):
* lisp/gnus/gnus-agent.el (gnus-agent-unfetch-articles)
(gnus-agent-read-agentview, gnus-agent-expire-group-1)
(gnus-agent-request-article, gnus-agent-regenerate-group)
(gnus-agent-update-files-total-fetched-for)
(gnus-agent-update-view-total-fetched-for):
* lisp/gnus/gnus-cache.el (gnus-cache-read-active)
(gnus-cache-update-file-total-fetched-for)
(gnus-cache-update-overview-total-fetched-for):
* lisp/gnus/gnus-cloud.el (gnus-cloud-file-new-p):
* lisp/gnus/gnus-score.el (gnus-score-score-files):
* lisp/gnus/gnus-start.el (gnus-save-newsrc-file)
(gnus-master-read-slave-newsrc):
* lisp/gnus/gnus-sum.el (gnus-summary-import-article):
* lisp/gnus/gnus-util.el (gnus-file-newer-than)
(gnus-cache-file-contents):
* lisp/gnus/mail-source.el (mail-source-delete-old-incoming)
(mail-source-callback, mail-source-movemail):
* lisp/gnus/nneething.el (nneething-create-mapping)
(nneething-make-head):
* lisp/gnus/nnfolder.el (nnfolder-read-folder):
* lisp/gnus/nnheader.el (nnheader-file-size)
(nnheader-insert-nov-file):
* lisp/gnus/nnmail.el (nnmail-activate):
* lisp/gnus/nnmaildir.el (nnmaildir--group-maxnum)
(nnmaildir--new-number, nnmaildir--update-nov)
(nnmaildir--scan, nnmaildir-request-scan)
(nnmaildir-request-update-info)
(nnmaildir-request-expire-articles):
* lisp/gnus/nnmh.el (nnmh-request-list-1)
(nnmh-request-expire-articles, nnmh-update-gnus-unreads):
* lisp/gnus/nnml.el (nnml-request-expire-articles):
* lisp/gnus/spam-stat.el (spam-stat-save, spam-stat-load)
(spam-stat-process-directory, spam-stat-test-directory):
* lisp/ido.el (ido-directory-too-big-p)
(ido-file-name-all-completions):
* lisp/image-dired.el (image-dired-get-thumbnail-image)
(image-dired-create-thumb-1):
* lisp/info.el (info-insert-file-contents):
* lisp/ls-lisp.el (ls-lisp-insert-directory)
(ls-lisp-handle-switches, ls-lisp-classify-file)
(ls-lisp-format):
* lisp/mail/blessmail.el:
* lisp/mail/feedmail.el (feedmail-default-date-generator)
(feedmail-default-message-id-generator):
* lisp/mail/mailabbrev.el (mail-abbrevs-sync-aliases)
(mail-abbrevs-setup):
* lisp/mail/mspools.el (mspools-size-folder):
* lisp/mail/rmail.el (rmail-insert-inbox-text):
* lisp/mail/sendmail.el (sendmail-sync-aliases):
* lisp/mh-e/mh-alias.el (mh-alias-tstamp):
* lisp/net/ange-ftp.el (ange-ftp-parse-netrc)
(ange-ftp-write-region, ange-ftp-file-newer-than-file-p)
(ange-ftp-cf1):
* lisp/net/eudcb-mab.el (eudc-mab-query-internal):
* lisp/net/eww.el (eww-read-bookmarks):
* lisp/net/netrc.el (netrc-parse):
* lisp/net/newst-backend.el (newsticker--image-get):
* lisp/nxml/rng-loc.el (rng-get-parsed-schema-locating-file):
* lisp/obsolete/fast-lock.el (fast-lock-save-cache):
* lisp/obsolete/vc-arch.el (vc-arch-state)
(vc-arch-diff3-rej-p):
* lisp/org/ob-eval.el (org-babel--shell-command-on-region):
* lisp/org/org-attach.el (org-attach-commit):
* lisp/org/org-macro.el (org-macro-initialize-templates):
* lisp/org/org.el (org-babel-load-file)
(org-file-newer-than-p):
* lisp/org/ox-html.el (org-html-format-spec):
* lisp/org/ox-publish.el (org-publish-find-date)
(org-publish-cache-ctime-of-src):
* lisp/pcmpl-gnu.el (pcomplete/tar):
* lisp/pcmpl-rpm.el (pcmpl-rpm-packages):
* lisp/play/cookie1.el (cookie-snarf):
* lisp/progmodes/cmacexp.el (c-macro-expansion):
* lisp/ps-bdf.el (bdf-file-mod-time):
* lisp/server.el (server-ensure-safe-dir):
* lisp/simple.el (shell-command-on-region):
* lisp/speedbar.el (speedbar-item-info-file-helper)
(speedbar-check-obj-this-line):
* lisp/thumbs.el (thumbs-cleanup-thumbsdir):
* lisp/time.el (display-time-mail-check-directory)
(display-time-file-nonempty-p):
* lisp/url/url-cache.el (url-is-cached):
* lisp/url/url-file.el (url-file-asynch-callback):
* lisp/vc/diff-mode.el (diff-delete-if-empty):
* lisp/vc/pcvs-info.el (cvs-fileinfo-from-entries):
* lisp/vc/vc-bzr.el (vc-bzr-state-heuristic):
* lisp/vc/vc-cvs.el (vc-cvs-checkout-model)
(vc-cvs-state-heuristic, vc-cvs-merge-news)
(vc-cvs-retrieve-tag, vc-cvs-parse-status, vc-cvs-parse-entry):
* lisp/vc/vc-hg.el (vc-hg--slurp-hgignore-1)
(vc-hg--ignore-patterns-valid-p)
(vc-hg--cached-dirstate-search, vc-hg-state-fast):
* lisp/vc/vc-hooks.el (vc-after-save):
* lisp/vc/vc-rcs.el (vc-rcs-workfile-is-newer):
* lisp/vc/vc-svn.el (vc-svn-merge-news, vc-svn-parse-status):
* lisp/vc/vc.el (vc-checkout, vc-checkin, vc-revert-file):
* lisp/xdg.el (xdg-mime-apps):
Prefer (file-attribute-size A) to (nth 7 A), and similarly
for other file attributes accessors.
* doc/lispref/files.texi (File Attributes):
* doc/lispref/intro.texi (Version Info):
* doc/lispref/os.texi (Idle Timers):
* lisp/erc/erc.el (erc-string-to-emacs-time):
* lisp/files.el (file-attribute-access-time)
(file-attribute-modification-time)
(file-attribute-status-change-time):
* lisp/net/tramp-compat.el:
(tramp-compat-file-attribute-modification-time)
(tramp-compat-file-attribute-size):
* src/buffer.c (syms_of_buffer):
* src/editfns.c (Fget_internal_run_time):
* src/fileio.c (Fvisited_file_modtime)
(Fset_visited_file_modtime):
* src/keyboard.c (Fcurrent_idle_time):
* src/process.c (Fprocess_attributes):
Defer implementation details about timestamp format to the
section that talks about timestamp format, to make it easier
to change the documentation later if timestamp formats are
extended.
* lisp/gnus/gnus-util.el (gnus-file-newer-than):
* lisp/speedbar.el (speedbar-check-obj-this-line):
* lisp/vc/vc-rcs.el (vc-rcs-workfile-is-newer):
Prefer time-less-p to doing it by hand.
* lisp/ls-lisp.el (ls-lisp-format): Inode numbers are no longer conses.
* lisp/vc/vc-bzr.el (vc-bzr-state-heuristic):
Use eql, not eq, to compare integers that might be bignums.
* lisp/org/ox-publish.el (org-publish-cache-ctime-of-src):
Prefer float-time to doing time arithmetic by hand.
2018-09-23 18:30:46 -07:00
|
|
|
|
;; `(,(file-attribute-access-time fattribs)
|
|
|
|
|
;; ,(file-attribute-size fattribs) ,f)))
|
2015-09-17 12:28:45 -07:00
|
|
|
|
;; (directory-files (image-dired-dir) t ".+\\.thumb\\..+$"))
|
2022-09-18 02:03:16 +02:00
|
|
|
|
;; ;; Sort function. Compare time between two files.
|
2011-05-23 14:57:17 -03:00
|
|
|
|
;; (lambda (l1 l2)
|
2007-04-22 13:44:05 +00:00
|
|
|
|
;; (time-less-p (car l1) (car l2)))))
|
|
|
|
|
;; (dirsize (apply '+ (mapcar (lambda (x) (cadr x)) files))))
|
|
|
|
|
;; (while (> dirsize image-dired-dir-max-size)
|
|
|
|
|
;; (y-or-n-p
|
|
|
|
|
;; (format "Size of thumbnail directory: %d, delete old file %s? "
|
|
|
|
|
;; dirsize (cadr (cdar files))))
|
|
|
|
|
;; (delete-file (cadr (cdar files)))
|
|
|
|
|
;; (setq dirsize (- dirsize (car (cdar files))))
|
|
|
|
|
;; (setq files (cdr files)))))
|
|
|
|
|
|
|
|
|
|
(provide 'image-dired)
|
|
|
|
|
|
|
|
|
|
;;; image-dired.el ends here
|