diff options
author | Ulrich Müller <ulm@gentoo.org> | 2022-05-20 18:31:00 +0200 |
---|---|---|
committer | Ulrich Müller <ulm@gentoo.org> | 2022-05-20 18:31:00 +0200 |
commit | 46dd6ccf03f5dab9d86a6eca160ca94f2b67024c (patch) | |
tree | f079b1b1841f9bc2cb9bb0a2d040e08abf3206f2 | |
parent | Warn about some eclass documentation keywords (diff) | |
download | ebuild-mode-46dd6ccf03f5dab9d86a6eca160ca94f2b67024c.tar.gz ebuild-mode-46dd6ccf03f5dab9d86a6eca160ca94f2b67024c.tar.bz2 ebuild-mode-46dd6ccf03f5dab9d86a6eca160ca94f2b67024c.zip |
Protect against buffer-file-name being nil
* ebuild-mode.el (ebuild-mode, ebuild-repo-mode-maybe-enable):
Protect against buffer-file-name being nil. Bug 846569.
Bug: https://bugs.gentoo.org/846569
Signed-off-by: Ulrich Müller <ulm@gentoo.org>
-rw-r--r-- | ChangeLog | 5 | ||||
-rw-r--r-- | ebuild-mode.el | 14 |
2 files changed, 13 insertions, 6 deletions
@@ -1,3 +1,8 @@ +2022-05-20 Ulrich Müller <ulm@gentoo.org> + + * ebuild-mode.el (ebuild-mode, ebuild-repo-mode-maybe-enable): + Protect against buffer-file-name being nil. Bug 846569. + 2022-05-10 Ulrich Müller <ulm@gentoo.org> * ebuild-mode-keywords.el (ebuild-mode-keywords-eclassdoc-warn): diff --git a/ebuild-mode.el b/ebuild-mode.el index 33c3dab..569c2de 100644 --- a/ebuild-mode.el +++ b/ebuild-mode.el @@ -348,11 +348,12 @@ Optional argument LIMIT restarts collection after that number of elements." (setq fill-column 72) (setq tab-width 4) (setq indent-tabs-mode t) - (if (let ((case-fold-search t)) - (string-match "\\.eclass\\'" - (file-name-sans-versions buffer-file-name))) - ;; Eclass documentation uses two spaces after sentence ends - (set (make-local-variable 'sentence-end-double-space) t))) + (and buffer-file-name + (let ((case-fold-search t)) + (string-match "\\.eclass\\'" + (file-name-sans-versions buffer-file-name))) + ;; Eclass documentation uses two spaces after sentence ends + (set (make-local-variable 'sentence-end-double-space) t))) (add-hook 'ebuild-mode-hook (lambda () (font-lock-add-keywords @@ -624,7 +625,8 @@ and `all-completions' for details." "Enable `ebuild-repo-mode' when the file is in an ebuild repository." ;; We assume that we are in an ebuild repository we find a file ;; "profiles/repo_name" in any (nth level) parent dir - (and (locate-dominating-file buffer-file-name "profiles/repo_name") + (and buffer-file-name + (locate-dominating-file buffer-file-name "profiles/repo_name") ;; Don't enable the mode for patches (not (string-match "\\.\\(diff\\|patch\\)\\'" buffer-file-name)) (not (derived-mode-p 'diff-mode)) |