summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStefan Kangas <stefan@marxist.se>2021-03-20 01:10:37 +0100
committerStefan Kangas <stefan@marxist.se>2021-03-20 01:11:47 +0100
commit7607d1c4e854cf55701aef3446092d3f510697ce (patch)
treec6576ce0bb162f79964c8c568596a7691d76bb98
parent26dc070fa947d2f60a932e02167b4bdfd464939e (diff)
downloademacs-7607d1c4e854cf55701aef3446092d3f510697ce.tar.gz
Use lexical-binding in thumbs.el
* lisp/thumbs.el: Use lexical-binding. Remove redundant :group args. * test/lisp/thumbs-tests.el: New file.
-rw-r--r--lisp/thumbs.el51
-rw-r--r--test/lisp/thumbs-tests.el34
2 files changed, 53 insertions, 32 deletions
diff --git a/lisp/thumbs.el b/lisp/thumbs.el
index 957940bfe0c..c6a9a67b3f3 100644
--- a/lisp/thumbs.el
+++ b/lisp/thumbs.el
@@ -1,4 +1,4 @@
-;;; thumbs.el --- Thumbnails previewer for images files
+;;; thumbs.el --- Thumbnails previewer for images files -*- lexical-binding: t -*-
;; Copyright (C) 2004-2021 Free Software Foundation, Inc.
@@ -23,7 +23,7 @@
;;; Commentary:
-;; This package create two new modes: thumbs-mode and thumbs-view-image-mode.
+;; This package create two new modes: `thumbs-mode' and `thumbs-view-image-mode'.
;; It is used for basic browsing and viewing of images from within Emacs.
;; Minimal image manipulation functions are also available via external
;; programs. If you want to do more complex tasks like categorize and tag
@@ -34,7 +34,7 @@
;;
;; Thanks: Alex Schroeder <alex@gnu.org> for maintaining the package at some
;; time. The peoples at #emacs@freenode.net for numerous help. RMS
-;; for emacs and the GNU project.
+;; for Emacs and the GNU project.
;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;
@@ -68,29 +68,24 @@
(defcustom thumbs-thumbsdir (locate-user-emacs-file "thumbs")
"Directory to store thumbnails."
- :type 'directory
- :group 'thumbs)
+ :type 'directory)
(defcustom thumbs-geometry "100x100"
"Size of thumbnails."
- :type 'string
- :group 'thumbs)
+ :type 'string)
(defcustom thumbs-per-line 4
"Number of thumbnails per line to show in directory."
- :type 'integer
- :group 'thumbs)
+ :type 'integer)
(defcustom thumbs-max-image-number 16
"Maximum number of images initially displayed in thumbs buffer."
- :type 'integer
- :group 'thumbs)
+ :type 'integer)
(defcustom thumbs-thumbsdir-max-size 50000000
"Maximum size for thumbnails directory.
When it reaches that size (in bytes), a warning is sent."
- :type 'integer
- :group 'thumbs)
+ :type 'integer)
;; Unfortunately Windows XP has a program called CONVERT.EXE in
;; C:/WINDOWS/SYSTEM32/ for partitioning NTFS systems. So Emacs
@@ -103,49 +98,41 @@ When it reaches that size (in bytes), a warning is sent."
"/usr/X11R6/bin/convert"))
"Name of conversion program for thumbnails generation.
It must be \"convert\"."
- :type 'string
- :group 'thumbs)
+ :type 'string)
(defcustom thumbs-setroot-command
"xloadimage -onroot -fullscreen *"
"Command to set the root window."
- :type 'string
- :group 'thumbs)
+ :type 'string)
(defcustom thumbs-relief 5
"Size of button-like border around thumbnails."
- :type 'integer
- :group 'thumbs)
+ :type 'integer)
(defcustom thumbs-margin 2
"Size of the margin around thumbnails.
This is where you see the cursor."
- :type 'integer
- :group 'thumbs)
+ :type 'integer)
(defcustom thumbs-thumbsdir-auto-clean t
"If set, delete older file in the thumbnails directory.
Deletion is done at load time when the directory size is bigger
than `thumbs-thumbsdir-max-size'."
- :type 'boolean
- :group 'thumbs)
+ :type 'boolean)
(defcustom thumbs-image-resizing-step 10
"Step by which to resize image as a percentage."
- :type 'integer
- :group 'thumbs)
+ :type 'integer)
(defcustom thumbs-temp-dir temporary-file-directory
"Temporary directory to use.
Defaults to `temporary-file-directory'. Leaving it to
this value can let another user see some of your images."
- :type 'directory
- :group 'thumbs)
+ :type 'directory)
(defcustom thumbs-temp-prefix "emacsthumbs"
"Prefix to add to temp files."
- :type 'string
- :group 'thumbs)
+ :type 'string)
;; Initialize some variable, for later use.
(defvar-local thumbs-current-tmp-filename nil
@@ -210,7 +197,7 @@ reached."
,f)))
(directory-files (thumbs-thumbsdir) t (image-file-name-regexp)))
(lambda (l1 l2) (time-less-p (car l1) (car l2)))))
- (dirsize (apply '+ (mapcar (lambda (x) (cadr x)) files-list))))
+ (dirsize (apply #'+ (mapcar (lambda (x) (cadr x)) files-list))))
(while (> dirsize thumbs-thumbsdir-max-size)
(progn
(message "Deleting file %s" (cadr (cdar files-list))))
@@ -290,7 +277,7 @@ smaller according to whether INCREMENT is 1 or -1."
(subst-char-in-string
?\s ?\_
(apply
- 'concat
+ #'concat
(split-string filename "/")))))))
(defun thumbs-make-thumb (img)
@@ -618,7 +605,7 @@ Open another window."
(when (eolp) (forward-char)))
;; cleaning of old temp files
-(mapc 'delete-file
+(mapc #'delete-file
(directory-files (thumbs-temp-dir) t thumbs-temp-prefix))
;; Image modification routines
diff --git a/test/lisp/thumbs-tests.el b/test/lisp/thumbs-tests.el
new file mode 100644
index 00000000000..ee096138453
--- /dev/null
+++ b/test/lisp/thumbs-tests.el
@@ -0,0 +1,34 @@
+;;; thumbs-tests.el --- tests for thumbs.el -*- lexical-binding: t -*-
+
+;; Copyright (C) 2021 Free Software Foundation, Inc.
+
+;; This file is part of GNU Emacs.
+
+;; GNU Emacs is free software: you can redistribute it and/or modify
+;; it under the terms of the GNU General Public License as published by
+;; the Free Software Foundation, either version 3 of the License, or
+;; (at your option) any later version.
+
+;; 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
+;; along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>.
+
+;;; Code:
+
+(require 'ert)
+(require 'thumbs)
+
+(ert-deftest thumbs-tests-thumbsdir/create-if-missing ()
+ (let ((thumbs-thumbsdir (make-temp-file "thumbs-test" t)))
+ (unwind-protect
+ (progn
+ (delete-directory thumbs-thumbsdir)
+ (should (file-directory-p (thumbs-thumbsdir))))
+ (delete-directory thumbs-thumbsdir))))
+
+(provide 'thumbs-tests)
+;;; thumbs-tests.el ends here