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

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

[elpa] externals/scanner 6537d71 47/56: add image size customization and


From: Stefan Monnier
Subject: [elpa] externals/scanner 6537d71 47/56: add image size customization and update tests
Date: Fri, 10 Apr 2020 13:56:06 -0400 (EDT)

branch: externals/scanner
commit 6537d71c85a26c9b0f31b8ca7e6a80b90b868ca4
Author: Raffael Stocker <address@hidden>
Commit: Raffael Stocker <address@hidden>

    add image size customization and update tests
---
 Makefile        |  4 ++--
 scanner-test.el | 21 ++++++++-------------
 scanner.el      | 11 +++++++++--
 3 files changed, 19 insertions(+), 17 deletions(-)

diff --git a/Makefile b/Makefile
index 067ba3b..63dcf21 100644
--- a/Makefile
+++ b/Makefile
@@ -8,8 +8,8 @@
 EMACS = emacs
 EL = scanner.el
 TEST = scanner-test.el
-RUN_ENTRY = scanner.el
-TEST_ENTRY = scanner-test.el
+RUN_ENTRY = scanner.elc
+TEST_ENTRY = scanner-test.elc
 ELPA_EXT = dash
 LDFLAGS = -L ./dep/dash
 
diff --git a/scanner-test.el b/scanner-test.el
index 6c16de4..7b4ab9b 100644
--- a/scanner-test.el
+++ b/scanner-test.el
@@ -46,8 +46,6 @@
 
 
 ;;; Code:
-
-(load-file "scanner.el")
 (require 'scanner)
 (require 'dash)
 (require 'ert)
@@ -78,6 +76,7 @@
   (let ((scanner--available-switches nil)
        (scanner-image-format '(:image "fmt-img" :doc "fmt-doc"))
        (scanner-device-name "devname")
+       (scanner-image-size '(200 250))
        (-compare-fn #'string=))
     ;; known values are included with their switches
     (should (-is-infix-p '("-d" "devname") (scanner--scanimage-args "file"
@@ -110,6 +109,7 @@
        (scanner-scan-mode '(:image "Color" :doc "Gray"))
        (scanner-doc-papersize :a4)
        (scanner-paper-sizes '(:a4 (210 297)))
+       (scanner-image-size '(200 250))
        (-compare-fn #'string=))
     (should (-is-infix-p '("-o" "file") (scanner--scanimage-args "file" 
:image)))
     (should (-contains-p (scanner--scanimage-args "file" :image)
@@ -120,15 +120,9 @@
     (should (-contains-p (scanner--scanimage-args "file" :image)
                         "--resolution=600"))
     (should (-is-infix-p '("-x" "210") (scanner--scanimage-args "file" :doc)))
-    (should (-is-infix-p '("-y" "297") (scanner--scanimage-args "file" :doc))))
-  ;; doc args list with device specific args
-  (let ((scanner--available-switches '("--resolution" "-x" "-y" "--mode"))
-       (scanner-image-format '(:image "fmt-img" :doc "fmt-doc"))
-       (scanner-resolution '(:doc 300 :image 600))
-       (scanner-scan-mode '(:image "Color" :doc "Gray"))
-       (scanner-doc-papersize :a4)
-       (scanner-paper-sizes '(:a4 (210 297)))
-       (-compare-fn #'string=))
+    (should (-is-infix-p '("-y" "297") (scanner--scanimage-args "file" :doc)))
+    (should (-is-infix-p '("-x" "200") (scanner--scanimage-args "file" 
:image)))
+    (should (-is-infix-p '("-y" "250") (scanner--scanimage-args "file" 
:image)))
     (should (-is-infix-p '("-o" "file") (scanner--scanimage-args "file" :doc)))
     (should (-contains-p (scanner--scanimage-args "file" :doc)
                         "--format=fmt-doc"))
@@ -137,8 +131,9 @@
     (should (-contains-p (scanner--scanimage-args "file" :doc) "--mode=Gray"))
     (should (-contains-p (scanner--scanimage-args "file" :doc)
                         "--resolution=300"))
-    (should (-is-infix-p '("-x" "210") (scanner--scanimage-args "file" :doc)))
-    (should (-is-infix-p '("-y" "297") (scanner--scanimage-args "file" 
:doc)))))
+    (let ((scanner-image-size nil))
+      (should-not (-contains-p (scanner--scanimage-args "file" :image) "-x"))
+      (should-not (-contains-p (scanner--scanimage-args "file" :image) 
"-y")))))
 
 
 (ert-deftest scanner-test-tesseract-args ()
diff --git a/scanner.el b/scanner.el
index 3b0c788..d4c05fc 100644
--- a/scanner.el
+++ b/scanner.el
@@ -107,6 +107,11 @@ The value must be one of the keys in the paper sizes list."
   :type '(restricted-sexp :match-alternatives
                          ((lambda (k) (plist-member scanner-paper-sizes k)))))
 
+(defcustom scanner-image-size
+  '(200 250)
+  "Image size as list of (width height) in mm or nil."
+  :type '(list number number))
+
 (defcustom scanner-reverse-pages
   nil
   "If non-nil, reverse pages in document mode."
@@ -319,8 +324,10 @@ argument for the intermediate representation before 
conversion to
 the document format.  If any of the required options from
 ‘scanner--device-specific-switches’ are unavailable, they are
 simply dropped."
-  (let ((size (when (eq :doc type)
-               (plist-get scanner-paper-sizes scanner-doc-papersize))))
+  (let ((size (cond ((eq :doc type)
+                    (plist-get scanner-paper-sizes scanner-doc-papersize))
+                   ((eq :image type) scanner-image-size)
+                   (t nil))))
     (-flatten (list (and scanner-device-name
                         (list "-d" scanner-device-name))
                    (-when-let (fmt (or img-fmt



reply via email to

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