[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/show-font 6f878f50bc 18/54: Simplify the file name hand
From: |
ELPA Syncer |
Subject: |
[elpa] externals/show-font 6f878f50bc 18/54: Simplify the file name handler |
Date: |
Tue, 10 Sep 2024 03:58:57 -0400 (EDT) |
branch: externals/show-font
commit 6f878f50bc18b46b77e8e6588fbefa48af3161f1
Author: Protesilaos Stavrou <info@protesilaos.com>
Commit: Protesilaos Stavrou <info@protesilaos.com>
Simplify the file name handler
---
show-font.el | 30 ++++++++++--------------------
1 file changed, 10 insertions(+), 20 deletions(-)
diff --git a/show-font.el b/show-font.el
index bc403d6c53..f0e3739bdd 100644
--- a/show-font.el
+++ b/show-font.el
@@ -124,29 +124,19 @@ that all of them occur at least once in STRING."
(message "Still missing: %s" (mapconcat #'identity missing-characters ",
"))
nil)))
-;; NOTE 2024-08-24: Copied from `ready-player.el' by Alvaro Ramirez to
-;; quickly put this package together. I do not quite understand the
-;; mechanics of file handling yet. The idea of what I want is to get
-;; an empty buffer. Then I add contents there without making it
-;; appear modified.
(defun show-font-handler (operation &rest args)
"Handle the given I/O `file-name-handler-alist' OPERATION with ARGS.
Determine how to render the font file contents in a buffer."
- (pcase operation
- ('insert-file-contents
- (cl-destructuring-bind (filename visit _beg _end _replace) args
- (when visit
- (setq buffer-file-name filename))
- (list buffer-file-name (point-max))))
- ('file-attributes
- (let* ((file-name-handler-alist nil)
- (attributes (apply #'file-name-non-special
- (append (list operation) args))))
- ;; 7 is file size location
- ;; as per `file-attributes'.
- (setf (nth 7 attributes) 0)
- attributes))
- (_ (let ((inhibit-file-name-handlers
+ (cond
+ ((eq operation 'insert-file-contents)
+ (when-let ((filename (car args))
+ (visit (cadr args)))
+ (setq buffer-file-name filename)
+ (list buffer-file-name (point-max)))
+ (show-font--add-text))
+ ;; Handle any operation we do not know about. This is copied from
+ ;; the example show in (info "(elisp) Magic File Names").
+ (t (let ((inhibit-file-name-handlers
(cons #'show-font-handler
(and (eq inhibit-file-name-operation operation)
inhibit-file-name-handlers)))
- [elpa] branch externals/show-font created (now 6e10b12b5d), ELPA Syncer, 2024/09/10
- [elpa] externals/show-font 2f55db5bad 02/54: Fix rendering of title and subtitle in the given font, ELPA Syncer, 2024/09/10
- [elpa] externals/show-font bd9b392cf8 10/54: Simplify show-font--get-attribute, ELPA Syncer, 2024/09/10
- [elpa] externals/show-font abb3e13345 17/54: Add TODO to refine show-font--get-pangram, ELPA Syncer, 2024/09/10
- [elpa] externals/show-font 6f878f50bc 18/54: Simplify the file name handler,
ELPA Syncer <=
- [elpa] externals/show-font f8e4484bcd 20/54: Clarity show-font-pangram-p doc string, ELPA Syncer, 2024/09/10
- [elpa] externals/show-font f90e03c5e8 22/54: Refine how the title faces are produced, ELPA Syncer, 2024/09/10
- [elpa] externals/show-font c10b077657 25/54: Add TODO about how best to support multiple languages, ELPA Syncer, 2024/09/10
- [elpa] externals/show-font b572bacf0c 26/54: Make the major mode disable line numbers locally, ELPA Syncer, 2024/09/10
- [elpa] externals/show-font 5cf734e21a 35/54: Define a button and use it to help the user install current file, ELPA Syncer, 2024/09/10
- [elpa] externals/show-font c5d7fd6e34 01/54: Add initial version of show-font, ELPA Syncer, 2024/09/10
- [elpa] externals/show-font 460da112ed 08/54: Add TODO about other operating systems, ELPA Syncer, 2024/09/10
- [elpa] externals/show-font a1ffe8afdf 05/54: Autoload show-font-extensions-regexp to make the package install correctly, ELPA Syncer, 2024/09/10
- [elpa] externals/show-font 1ab166f5df 14/54: Remove done to-do items, ELPA Syncer, 2024/09/10
- [elpa] externals/show-font 791416d748 16/54: Rework how we expand the pangrams for the defcustom :type, ELPA Syncer, 2024/09/10