Interim fix, no gpg key
This commit is contained in:
@@ -333,6 +333,42 @@ With prefix ARG, prompt for a pattern then select from matches."
|
||||
(define-key azos/roam-keymap (kbd "B") #'azos/roam/backup)
|
||||
#+end_src
|
||||
|
||||
** Printing
|
||||
|
||||
#+begin_src emacs-lisp
|
||||
(defun azos/print-buffer (&optional arg)
|
||||
"Print the current buffer.
|
||||
For image/PDF/doc buffers, sends the file path to lp directly.
|
||||
For text buffers, uses lpr-buffer.
|
||||
With C-u, interactively prompt for scaling, B&W, and orientation options."
|
||||
(interactive "P")
|
||||
(let* ((image-p (derived-mode-p 'image-mode 'pdf-view-mode 'doc-view-mode))
|
||||
(scale (when arg (y-or-n-p "Fit to page? ")))
|
||||
(bw (when arg (y-or-n-p "Black and white? ")))
|
||||
(landscape (when (and arg image-p) (y-or-n-p "Landscape? ")))
|
||||
(lp-opts (concat
|
||||
(when scale " -o fit-to-page")
|
||||
(when bw " -o print-color-mode=monochrome")
|
||||
(when landscape " -o landscape"))))
|
||||
(if image-p
|
||||
(if buffer-file-name
|
||||
(progn
|
||||
(shell-command
|
||||
(concat "lp" lp-opts " " (shell-quote-argument buffer-file-name)))
|
||||
(message "Sent %s to printer%s%s%s."
|
||||
(file-name-nondirectory buffer-file-name)
|
||||
(if scale " [scaled]" "")
|
||||
(if bw " [B&W]" "")
|
||||
(if landscape " [landscape]" "")))
|
||||
(error "Buffer has no associated file"))
|
||||
(let ((lpr-switches
|
||||
(append lpr-switches
|
||||
(when bw '("-o print-color-mode=monochrome")))))
|
||||
(lpr-buffer)))))
|
||||
|
||||
(define-key azos/global-minor-mode/open-keymap (kbd "P") #'azos/print-buffer)
|
||||
#+end_src
|
||||
|
||||
* Provide
|
||||
|
||||
#+begin_src emacs-lisp
|
||||
|
||||
Reference in New Issue
Block a user