Skip to content

Commit

Permalink
Find path of keyword files during compilation. (#40)
Browse files Browse the repository at this point in the history
  • Loading branch information
jobbflykt authored Nov 13, 2024
1 parent ef9cf21 commit 72719e3
Showing 1 changed file with 17 additions and 8 deletions.
25 changes: 17 additions & 8 deletions x509-mode.el
Original file line number Diff line number Diff line change
Expand Up @@ -328,14 +328,23 @@ For simple cases, COMPOSE-URL-FN returns its argument unchanged."
(defun x509--load-data-file (filename)
"Split FILENAME linewise into a list.
Skip blank lines and comment lines. Return list."
(with-temp-buffer
(insert-file-contents
(if (null load-file-name)
filename
(expand-file-name filename (file-name-directory load-file-name))))
(cl-remove-if
(lambda (s) (string-match-p "^ *\\(?:#\\|$\\)" s))
(split-string (buffer-string) "\n")))))
;; Try to guess path to filename. It may not be in the current directory
;; when compiling.
(let ((path (cond ((bound-and-true-p byte-compile-current-file)
(expand-file-name filename
(file-name-directory
byte-compile-current-file)))
((bound-and-true-p load-file-name)
(expand-file-name filename
(file-name-directory
load-file-name)))
(t
filename))))
(with-temp-buffer
(insert-file-contents path)
(cl-remove-if
(lambda (s) (string-match-p "^ *\\(?:#\\|$\\)" s))
(split-string (buffer-string) "\n"))))))

(eval-when-compile
(defconst x509--keywords (regexp-opt (x509--load-data-file "keywords.txt"))))
Expand Down

0 comments on commit 72719e3

Please sign in to comment.