Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Try harder to determine path of keyword files during compilation. #40

Merged
merged 1 commit into from
Nov 13, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading