From 851ab40bb97ed3dddf4c50f48762e2d6707deeec Mon Sep 17 00:00:00 2001 From: Marek L Date: Sat, 8 Jun 2024 19:35:33 +0100 Subject: [PATCH] Extract regexp for .ipkg sourcedir option to constant and update the regexp to include also double quotes. Why: In Idris2 the sourcedir option has double quotes. Relates to: https://github.com/idris-hackers/idris-mode/issues/624 --- idris-ipkg-mode.el | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/idris-ipkg-mode.el b/idris-ipkg-mode.el index 3fe70b9d..d4e81fd9 100644 --- a/idris-ipkg-mode.el +++ b/idris-ipkg-mode.el @@ -86,6 +86,9 @@ (defconst idris-ipkg-font-lock-defaults `(,idris-ipkg-keywords)) +(defconst idris-ipkg-sourcedir-re + "^sourcedir\\s-*=\\s-*\"?\\([a-zA-Z/0-9]+\\)\"?") +;; "^\\s-*sourcedir\\s-*=\\s-*\\(\\sw+\\)" ;;; Completion @@ -142,7 +145,7 @@ (goto-char (point-min)) (when (and (file-exists-p src-dir) (file-directory-p src-dir) - (re-search-forward "^sourcedir\\s-*=\\s-*\\([a-zA-Z/0-9]+\\)" nil t)) + (re-search-forward idris-ipkg-sourcedir-re nil t)) (let ((start (match-beginning 1)) (end (match-end 1)) (map (make-sparse-keymap))) @@ -304,9 +307,7 @@ arguments." (save-excursion (goto-char (point-min)) (let ((found - (re-search-forward "^\\s-*sourcedir\\s-*=\\s-*\\(\\sw+\\)" - nil - t))) + (re-search-forward idris-ipkg-sourcedir-re nil t))) (if found (let ((subdir (buffer-substring-no-properties (match-beginning 1) (match-end 1)))) (concat (file-name-directory basename) subdir))