emacs-elpa-diffs
[Top][All Lists]
Advanced

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

[elpa] externals/scanner d0c4981 2/5: add a ‘:whatever’ paper size to l


From: Stefan Monnier
Subject: [elpa] externals/scanner d0c4981 2/5: add a ‘:whatever’ paper size to let scanimage use maximum scan area
Date: Mon, 15 Mar 2021 22:22:22 -0400 (EDT)

branch: externals/scanner
commit d0c4981aba1ee2dffa398db8ef601fa4a9c5e0cf
Author: Raffael Stocker <r.stocker@mnet-mail.de>
Commit: Raffael Stocker <r.stocker@mnet-mail.de>

    add a ‘:whatever’ paper size to let scanimage use maximum scan area
    
    * scanner.el (scanner-doc-papersize): allow :whatever as key
             (scanner-select-papersize): add :whatever to selection
---
 scanner-test.el |  7 +++++++
 scanner.el      | 15 ++++++++++-----
 2 files changed, 17 insertions(+), 5 deletions(-)

diff --git a/scanner-test.el b/scanner-test.el
index cb8a93f..64668c9 100644
--- a/scanner-test.el
+++ b/scanner-test.el
@@ -116,6 +116,13 @@
                               "-x"))
       (should-not (-contains-p (scanner--scanimage-args :image
                                                        switches "jpeg")
+                              "-y")))
+    (let ((scanner-doc-papersize :whatever))
+      (should-not (-contains-p (scanner--scanimage-args  :doc
+                                                        switches "jpeg")
+                              "-x"))
+      (should-not (-contains-p (scanner--scanimage-args :doc
+                                                       switches "jpeg")
                               "-y")))))
 
 (ert-deftest scanner-test-make-scanimage-command ()
diff --git a/scanner.el b/scanner.el
index 0e518d1..9f3df3c 100644
--- a/scanner.el
+++ b/scanner.el
@@ -111,9 +111,11 @@ the second is the height in mm."
 (defcustom scanner-doc-papersize
   :a4
   "Document paper size.
-The value must be one of the keys in the paper sizes list."
+The value must be one of the keys in the paper sizes list, or ‘:whatever’ to
+use whatever scanimage thinks is right."
   :type '(restricted-sexp :match-alternatives
-                                                 ((lambda (k) (plist-member 
scanner-paper-sizes k)))))
+                                                 ((lambda (k) (or 
(plist-member scanner-paper-sizes k)
+                                                                         (eq k 
:whatever))))))
 
 (defcustom scanner-image-size
   '(200 250)
@@ -481,9 +483,12 @@ them.  Otherwise, return nil."
 (defun scanner-select-papersize (size)
   "Select the papersize SIZE for document scanning."
   (interactive
-   (let ((choices (delq nil (mapcar (lambda (x) (and (keywordp x)
-                                                                               
                (substring (symbol-name x) 1)))
-                                                                       
scanner-paper-sizes))))
+   (let ((choices (append (delq nil
+                                                               (mapcar (lambda 
(x)
+                                                                               
  (and (keywordp x)
+                                                                               
           (substring (symbol-name x) 1)))
+                                                                               
scanner-paper-sizes))
+                                                 '("whatever"))))
      (list (intern (concat ":"
                                                   (completing-read "Papersize: 
" choices nil t))))))
   (setq scanner-doc-papersize size))



reply via email to

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