Function: ede-do-dirmatch

ede-do-dirmatch is a byte-compiled function defined in auto.el.gz.

Signature

(ede-do-dirmatch ARG &rest ARGS)

Implementations

(ede-do-dirmatch (DIRMATCH ede-project-autoload-dirmatch) FILE) in `ede/auto.el'.

Does DIRMATCH match the filename FILE.

Source Code

;; Defined in /usr/src/emacs/lisp/cedet/ede/auto.el.gz
(cl-defmethod ede-do-dirmatch ((dirmatch ede-project-autoload-dirmatch) file)
  "Does DIRMATCH match the filename FILE."
  (let ((fc (ede-calc-fromconfig dirmatch)))

    (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")))
    ))