emacs-diffs
[Top][All Lists]
Advanced

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

master 7607d1c 1/2: Use lexical-binding in thumbs.el


From: Stefan Kangas
Subject: master 7607d1c 1/2: Use lexical-binding in thumbs.el
Date: Fri, 19 Mar 2021 20:27:10 -0400 (EDT)

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

    Use lexical-binding in thumbs.el
    
    * lisp/thumbs.el: Use lexical-binding.  Remove redundant :group args.
    * test/lisp/thumbs-tests.el: New file.
---
 lisp/thumbs.el            | 51 ++++++++++++++++++-----------------------------
 test/lisp/thumbs-tests.el | 34 +++++++++++++++++++++++++++++++
 2 files changed, 53 insertions(+), 32 deletions(-)

diff --git a/lisp/thumbs.el b/lisp/thumbs.el
index 957940b..c6a9a67 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 0000000..ee09613
--- /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



reply via email to

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