[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Emacs-diffs] scratch/last-cedet-merge b4d1399 14/37: EDE: Rework config
From: |
David Engster |
Subject: |
[Emacs-diffs] scratch/last-cedet-merge b4d1399 14/37: EDE: Rework config file detection |
Date: |
Sun, 22 Jan 2017 21:26:32 +0000 (UTC) |
branch: scratch/last-cedet-merge
commit b4d1399dc6a3f5493ce62b5231a065ba82d1012b
Author: Eric Ludlam <address@hidden>
Commit: David Engster <address@hidden>
EDE: Rework config file detection
* lisp/cedet/ede/auto.el (ede-calc-fromconfig): New.
(ede-dirmatch-installed, ede-do-dirmatch): Use above to find config
file.
---
lisp/cedet/ede/auto.el | 111 +++++++++++++++++++++---------------------------
1 file changed, 49 insertions(+), 62 deletions(-)
diff --git a/lisp/cedet/ede/auto.el b/lisp/cedet/ede/auto.el
index 6c0e588..a77de92 100644
--- a/lisp/cedet/ede/auto.el
+++ b/lisp/cedet/ede/auto.el
@@ -63,74 +63,61 @@ location is varied dependent on other complex criteria,
this class
can be used to define that match without loading the specific project
into memory.")
-(cl-defmethod ede-dirmatch-installed ((dirmatch ede-project-autoload-dirmatch))
- "Return non-nil if the tool DIRMATCH might match is installed on the system."
+(cl-defmethod ede-calc-fromconfig ((dirmatch ede-project-autoload-dirmatch))
+ "Calculate the value of :fromconfig from DIRMATCH."
(let ((fc (oref dirmatch fromconfig)))
+ (cond ((stringp fc) fc)
+ ((functionp fc) (funcall fc))
+ (t (error "Unknown dirmatch object match style.")))
+ ))
- (cond
- ;; If the thing to match is stored in a config file.
- ((stringp fc)
- (file-exists-p fc))
-
- ;; Add new types of dirmatches here.
-
- ;; Error for weird stuff
- (t (error "Unknown dirmatch type.")))))
+(cl-defmethod ede-dirmatch-installed ((dirmatch ede-project-autoload-dirmatch))
+ "Return non-nil if the tool DIRMATCH might match is installed on the system."
+ (file-exists-p (ede-calc-fromconfig dirmatch)))
(cl-defmethod ede-do-dirmatch ((dirmatch ede-project-autoload-dirmatch) file)
"Does DIRMATCH match the filename FILE."
- (let ((fc (oref dirmatch fromconfig)))
-
- (cond
- ;; If the thing to match is stored in a config file.
- ((stringp fc)
- (when (file-exists-p fc)
- (let ((matchstring
- (if (slot-boundp dirmatch 'configdatastash)
- (oref dirmatch configdatastash)
- nil)))
- (when (and (not matchstring) (not (slot-boundp dirmatch
'configdatastash)))
- (save-current-buffer
- (let* ((buff (get-file-buffer fc))
- (readbuff
- (let ((find-file-hook nil)) ;; Disable ede from recursing
- (find-file-noselect fc))))
- (set-buffer readbuff)
- (save-excursion
- (goto-char (point-min))
- (when (re-search-forward (oref dirmatch configregex) nil t)
- (setq matchstring
- (match-string (or (oref dirmatch configregexidx)
0)))))
- (if (not buff) (kill-buffer readbuff))))
- (when matchstring
- ;; If this dirmatch only finds subdirs of matchstring, then
- ;; force matchstring to be a directory.
- (when (oref dirmatch subdir-only)
- (setq matchstring (file-name-as-directory matchstring)))
- ;; Convert matchstring to a regexp
- (setq matchstring (concat "^" (regexp-quote matchstring)))
- ;; Stash it for later.
- (oset dirmatch configdatastash matchstring))
- ;; Debug
- ;;(message "Stashing config data for dirmatch %S as %S"
(eieio-object-name dirmatch) matchstring)
- )
- ;;(message "dirmatch %s against %s" matchstring (expand-file-name
file))
- ;; Match against our discovered string
- (setq file (file-name-as-directory (expand-file-name file)))
- (and matchstring (string-match matchstring (expand-file-name file))
- (or (not (oref dirmatch subdir-only))
- (not (= (match-end 0) (length file))))
- )
- )))
-
- ;; Add new matches here
- ;; ((stringp somenewslot ...)
- ;; )
-
- ;; Error if none others known
- (t
- (error "Unknown dirmatch object match style.")))
+ (let ((fc (ede-calc-fromconfig dirmatch)))
+
+ (when (file-exists-p fc)
+ (let ((matchstring
+ (if (slot-boundp dirmatch 'configdatastash)
+ (oref dirmatch configdatastash)
+ nil)))
+ (when (and (not matchstring) (not (slot-boundp dirmatch
'configdatastash)))
+ (save-current-buffer
+ (let* ((buff (get-file-buffer fc))
+ (readbuff
+ (let ((find-file-hook nil)) ;; Disable ede from recursing
+ (find-file-noselect fc))))
+ (set-buffer readbuff)
+ (save-excursion
+ (goto-char (point-min))
+ (when (re-search-forward (oref dirmatch configregex) nil t)
+ (setq matchstring
+ (match-string (or (oref dirmatch configregexidx) 0)))))
+ (if (not buff) (kill-buffer readbuff))))
+ (when matchstring
+ ;; If this dirmatch only finds subdirs of matchstring, then
+ ;; force matchstring to be a directory.
+ (when (oref dirmatch subdir-only)
+ (setq matchstring (file-name-as-directory matchstring)))
+ ;; Convert matchstring to a regexp
+ (setq matchstring (concat "^" (regexp-quote matchstring)))
+ ;; Stash it for later.
+ (oset dirmatch configdatastash matchstring))
+ ;; Debug
+ ;;(message "Stashing config data for dirmatch %S as %S"
(eieio-object-name dirmatch) matchstring)
+ )
+ ;;(message "dirmatch %s against %s" matchstring (expand-file-name file))
+ ;; Match against our discovered string
+ (setq file (file-name-as-directory (expand-file-name file)))
+ (and matchstring (string-match matchstring (expand-file-name file))
+ (or (not (oref dirmatch subdir-only))
+ (not (= (match-end 0) (length file))))
+ )
+ ))
))
(declare-function ede-directory-safe-p "ede")
- [Emacs-diffs] scratch/last-cedet-merge 40dd3d9 02/37: semantic: Do not add enum-type for every type, (continued)
- [Emacs-diffs] scratch/last-cedet-merge 40dd3d9 02/37: semantic: Do not add enum-type for every type, David Engster, 2017/01/22
- [Emacs-diffs] scratch/last-cedet-merge a7276f6 08/37: ; semantic: Add TODO comment regarding arg indexing, David Engster, 2017/01/22
- [Emacs-diffs] scratch/last-cedet-merge 5d6f4b8 05/37: EDE: Fix slot type in ede-proj-target-makefile, David Engster, 2017/01/22
- [Emacs-diffs] scratch/last-cedet-merge ec4505d 17/37: semantic: Accept FLAGS in texinfo-mode for analyzing completions, David Engster, 2017/01/22
- [Emacs-diffs] scratch/last-cedet-merge 0391760 13/37: semantic: Do not strip '*' from operator, David Engster, 2017/01/22
- [Emacs-diffs] scratch/last-cedet-merge c2d4ad8 23/37: semantic: Update keybinings for grammar mode, David Engster, 2017/01/22
- [Emacs-diffs] scratch/last-cedet-merge 7308eaf 18/37: semantic: Accept FLAGS parameter for makefile-mode for analyzing completions, David Engster, 2017/01/22
- [Emacs-diffs] scratch/last-cedet-merge cc30b46 11/37: EDE: Move ede-global-list-sanity-check to ede/files.el, David Engster, 2017/01/22
- [Emacs-diffs] scratch/last-cedet-merge 95f8a69 29/37: semantic: More C grammar optimizations, David Engster, 2017/01/22
- [Emacs-diffs] scratch/last-cedet-merge 2b42323 35/37: EDE: Fix for project detection, David Engster, 2017/01/22
- [Emacs-diffs] scratch/last-cedet-merge b4d1399 14/37: EDE: Rework config file detection,
David Engster <=
- [Emacs-diffs] scratch/last-cedet-merge deaa8c9 24/37: semantic: New function to find library with macro definition, David Engster, 2017/01/22
- [Emacs-diffs] scratch/last-cedet-merge 6b57c5b 20/37: semantic: Introduce `semantic-analyze-tag-type-members', David Engster, 2017/01/22
- [Emacs-diffs] scratch/last-cedet-merge 0a2b38b 26/37: EDE: Expand file name, David Engster, 2017/01/22
- [Emacs-diffs] scratch/last-cedet-merge fb127f2 34/37: semantic: C grammar fixes, David Engster, 2017/01/22
- [Emacs-diffs] scratch/last-cedet-merge f11e08f 10/37: semantic: Fix wisent parser recursion, David Engster, 2017/01/22
- [Emacs-diffs] scratch/last-cedet-merge 47471b9 12/37: EDE: Add missing require and silence byte compiler, David Engster, 2017/01/22
- [Emacs-diffs] scratch/last-cedet-merge 6ca095c 21/37: semantic: Add autoload for Add autoload for `semantic-analyze-debug-assist', David Engster, 2017/01/22
- [Emacs-diffs] scratch/last-cedet-merge 5cb7aed 22/37: semantic: New c-mode override for analyzing tag type members, David Engster, 2017/01/22
- [Emacs-diffs] scratch/last-cedet-merge 8571383 16/37: semantic: Incorporate local scope when finding type, David Engster, 2017/01/22
- [Emacs-diffs] scratch/last-cedet-merge 74263b1 37/37: semantic: Change unary expression rule, David Engster, 2017/01/22