Make QR code buffer readonly

This commit is contained in:
Bram Schoenmakers 2024-02-15 21:27:23 +01:00
parent 73a87ed767
commit 68b36fc922
Signed by: bram
GPG key ID: 0CCD19DFDC63258F
2 changed files with 4 additions and 0 deletions

View file

@ -931,6 +931,7 @@ Which covers my (potential) GPG/SSH usage within Emacs. Now, anytime a I perform
(with-current-buffer (get-buffer-create "*qr*") (with-current-buffer (get-buffer-create "*qr*")
;; in case the buffer still exists and image-mode is active ;; in case the buffer still exists and image-mode is active
(fundamental-mode) (fundamental-mode)
(read-only-mode -1)
(erase-buffer) (erase-buffer)
(insert text) (insert text)
(let ((file-format (let ((file-format
@ -938,6 +939,7 @@ Which covers my (potential) GPG/SSH usage within Emacs. Now, anytime a I perform
(call-process-region nil nil "qrencode" t t nil "-o" "-" "-t" file-format) (call-process-region nil nil "qrencode" t t nil "-o" "-" "-t" file-format)
(when (and (display-graphic-p) (string= file-format "PNG")) (when (and (display-graphic-p) (string= file-format "PNG"))
(image-mode))) (image-mode)))
(read-only-mode)
(display-buffer (current-buffer)))) (display-buffer (current-buffer))))
#+end_src #+end_src

View file

@ -17,6 +17,7 @@ This function relies on qrencode(1) being present in your $PATH."
(with-current-buffer (get-buffer-create "*qr*") (with-current-buffer (get-buffer-create "*qr*")
;; in case the buffer still exists and image-mode is active ;; in case the buffer still exists and image-mode is active
(fundamental-mode) (fundamental-mode)
(read-only-mode -1)
(erase-buffer) (erase-buffer)
(insert text) (insert text)
(let ((file-format (let ((file-format
@ -24,4 +25,5 @@ This function relies on qrencode(1) being present in your $PATH."
(call-process-region nil nil "qrencode" t t nil "-o" "-" "-t" file-format) (call-process-region nil nil "qrencode" t t nil "-o" "-" "-t" file-format)
(when (and (display-graphic-p) (string= file-format "PNG")) (when (and (display-graphic-p) (string= file-format "PNG"))
(image-mode))) (image-mode)))
(read-only-mode)
(display-buffer (current-buffer)))) (display-buffer (current-buffer))))