branch: externals/scanner commit f54542cff97a5ef7e08fd47fef6b55fd24fb8fb5 Author: Raffael Stocker <r.stoc...@mnet-mail.de> Commit: Raffael Stocker <r.stoc...@mnet-mail.de>
add configuration functions * scanner.el (scanner-toggle-use-unpaper): new function (scanner-select-page-layout): new function (scanner-select-input-pages): new function (scanner-select-output-pages): new function (scanner--select-rotation): new function (scanner-select-pre-rotation): new function (scanner-select-post-rotation): new function (scanner-select-pre-size): new function (scanner-select-post-size): new function --- scanner.el | 74 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 72 insertions(+), 2 deletions(-) diff --git a/scanner.el b/scanner.el index 809f812f2f..d58dc4facc 100644 --- a/scanner.el +++ b/scanner.el @@ -606,8 +606,6 @@ MSG is a format string, with ARGS passed to ‘format’." "Return scanner log buffer or create it." (get-buffer-create "*Scanner*")) - - (defun scanner--confirm-filenames (file &optional formats) "Confirm that FILE using the provided list of FORMATS may be overwritten. If no formats are provided, FILE is used as-is. Return t either @@ -624,6 +622,8 @@ them. Otherwise, return nil." t)) (confirm file)))) + + ;;;; commands ;;;###autoload (defun scanner-select-papersize (size) @@ -709,6 +709,76 @@ selection is made." "(" t ")"))))) (setq scanner-device-name device)) +;;;###autoload +(defun scanner-toggle-use-unpaper () + "Toggle use of unpaper." + (interactive) + (setq scanner-use-unpaper (not scanner-use-unpaper))) + +;;;###autoload +(defun scanner-select-page-layout (layout) + "Select the page layout." + (interactive (list (completing-read "Select page layout: " + '("single" "double" "none") + nil t))) + (setq scanner-unpaper-page-layout layout)) + +;;;###autoload +(defun scanner-select-input-pages (pages) + "Select the number of input PAGES." + (interactive "NSelect the number of input pages: ") + (setq scanner-unpaper-input-pages (min (max pages 1) 2))) + +;;;###autoload +(defun scanner-select-output-pages (pages) + "Select the number of output PAGES." + (interactive "NSelect the number of output pages: ") + (setq scanner-unpaper-output-pages (min (max pages 1) 2))) + +(defun scanner--select-rotation (prompt) + "Select rotation displaying PROMPT." + (let ((choice (completing-read prompt + '("clockwise" "counter-clockwise" + "none") + nil t))) + (list (cond ((string= choice "clockwise") 90) + ((string= choice "counter-clockwise") -90) + (t nil))))) + +;;;###autoload +(defun scanner-select-pre-rotation (rotation) + "Select the pre-rotation ROTATION (cw, ccw, none)." + (interactive (scanner--select-rotation "Select pre-rotation: ")) + (setq scanner-unpaper-pre-rotation rotation)) + +;;;###autoload +(defun scanner-select-post-rotation (rotation) + "Select the post-rotation ROTATION (cw, ccw, none)." + (interactive (scanner--select-rotation "Select post-rotation: ")) + (setq scanner-unpaper-post-rotation rotation)) + +;;;###autoload +(defun scanner-select-pre-size (size) + "Select the page SIZE before processing." + (interactive (list (completing-read "Select a pre-processing page size: " + (cons "none" + scanner--unpaper-sizes) + nil 'confirm))) + (setq scanner-unpaper-pre-size (if (string= "none" size) + nil + size))) + +;;;###autoload +(defun scanner-select-post-size (size) + "Select the page SIZE after processing." + (interactive (list (completing-read "Select a post-processing page size: " + (cons "none" + scanner--unpaper-sizes) + nil 'confirm))) + (setq scanner-unpaper-post-size (if (string= "none" size) + nil + size))) + ;;;###autoload (defun scanner-scan-document (npages filename) "Scan NPAGES pages and write the result to FILENAME.