lang/nim: fix invalid chars in nimsuggest tmp path

This commit is contained in:
Henrik Lissner 2018-08-30 23:36:32 +02:00
parent c1fa37245f
commit 147fa794d3
No known key found for this signature in database
GPG Key ID: 5F6C0EA160557395

View File

@ -10,16 +10,26 @@ nimsuggest isn't installed."
(nimsuggest-mode)))
(add-hook 'nim-mode-hook #'+nim|init-nimsuggest-mode)
(defun doom*nimsuggest--get-dirty-dir ()
"The original `nimsuggest--get-dirty-dir' incorrectly extracts the frame
(when IS-WINDOWS
;; TODO File PR/report upstream (https://github.com/nim-lang/nim-mode)
(defun doom*nimsuggest--get-dirty-dir ()
"The original `nimsuggest--get-dirty-dir' incorrectly extracts the frame
number from the string representation of `selected-frame', which can contain
characters that are illegal on Windows, causing invalid argument errors when
`nimsuggest--make-tempdir' tries to use it."
(let* ((frame-str (format "%s" (selected-frame)))
(frame-num-str (if (string-match " \\(0x[0-9a-z]+\\)>$" frame-str)
(match-string 1 frame-str))))
(file-name-as-directory (concat nimsuggest-dirty-directory frame-num-str))))
(advice-add #'nimsuggest--get-dirty-dir :override #'doom*nimsuggest--get-dirty-dir)
(let* ((frame-str (format "%s" (selected-frame)))
(frame-num-str (if (string-match " \\(0x[0-9a-z]+\\)>$" frame-str)
(match-string 1 frame-str))))
(file-name-as-directory (concat nimsuggest-dirty-directory frame-num-str))))
(advice-add #'nimsuggest--get-dirty-dir :override #'doom*nimsuggest--get-dirty-dir)
;; TODO File PR/report upstream (https://github.com/nim-lang/nim-mode)
(defun doom*nimsuggest--get-temp-file-name (path)
"Removes invalid characters from the temp file path, including the unicode
character that colon is replaced with, which is known to cause issues on
windows."
(replace-regexp-in-string "[* |<>\"?*]" "" path))
(advice-remove #'nimsuggest--get-temp-file-name :filter-return #'doom*nimsuggest--get-temp-file-name))
(map! :map nim-mode-map
:localleader