Skip to content

Commit

Permalink
Fix dylan-opt on buffer that isn't visiting a file
Browse files Browse the repository at this point in the history
In that case (buffer-file-name) returns nil.
  • Loading branch information
lassik committed Mar 20, 2021
1 parent a916e28 commit 055afa2
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions dylan-opt.el
Original file line number Diff line number Diff line change
Expand Up @@ -243,21 +243,22 @@ can be used to toggle the optimization highlighting on and off."

(defun dylan-opt--default-file-name ()
"Guess a default optimization file to match the current buffer."
(let* ((path (buffer-file-name))
(name (file-name-nondirectory path))
(stem (substring name 0 (string-match "\\.[^.]*$" name)))
(library dylan-buffer-library))
(expand-file-name
(concat (or (getenv "OPEN_DYLAN_USER_ROOT") "_build")
"/build/" library "/" stem ".el"))))
(and (buffer-file-name)
(let* ((path (buffer-file-name))
(name (file-name-nondirectory path))
(stem (substring name 0 (string-match "\\.[^.]*$" name)))
(library dylan-buffer-library))
(expand-file-name
(concat (or (getenv "OPEN_DYLAN_USER_ROOT") "_build")
"/build/" library "/" stem ".el")))))

;;;###autoload
(defun dylan-opt (opt-file)
"Show Dylan optimization faces according to OPT-FILE.
See the command `dylan-opt-mode', which this command enables."
(interactive
(list (let ((default (dylan-opt--default-file-name)))
(list (let ((default (or (dylan-opt--default-file-name) "")))
(read-file-name
"Dylan optimization file: "
(file-name-directory default) nil t
Expand Down

0 comments on commit 055afa2

Please sign in to comment.