Function: verilog-expand-dirnames
verilog-expand-dirnames is an interactive and byte-compiled function
defined in verilog-mode.el.gz.
Signature
(verilog-expand-dirnames &optional DIRNAMES)
Documentation
Return a list of existing directories given a list of wildcarded DIRNAMES.
Or, just the existing dirnames themselves if there are no wildcards.
Key Bindings
Source Code
;; Defined in /usr/src/emacs/lisp/progmodes/verilog-mode.el.gz
;;(progn (setq vh-mod "`foo" vh-foo "bar") (verilog-symbol-detick-text "bar `mod `undefed"))
(defun verilog-expand-dirnames (&optional dirnames)
"Return a list of existing directories given a list of wildcarded DIRNAMES.
Or, just the existing dirnames themselves if there are no wildcards."
;; Note this function is performance critical.
;; Do not call anything that requires disk access that cannot be cached.
(interactive)
(unless dirnames
(error "`verilog-library-directories' should include at least `.'"))
(save-match-data
(setq dirnames (reverse dirnames)) ; not nreverse
(let ((dirlist nil)
pattern dirfile dirfiles dirname root filename rest basefile)
(setq dirnames (mapcar #'substitute-in-file-name dirnames))
(while dirnames
(setq dirname (car dirnames)
dirnames (cdr dirnames))
(cond ((string-match (concat "^\\(\\|[^*?]*[/\\]\\)" ; root
"\\([^/\\]*[*?][^/\\]*\\)" ; filename with *?
"\\(.*\\)") ; rest
dirname)
(setq root (match-string 1 dirname)
filename (match-string 2 dirname)
rest (match-string 3 dirname)
pattern filename)
;; now replace those * and ? with .+ and .
;; use ^ and /> to get only whole file names
(setq pattern (verilog-string-replace-matches "[*]" ".+" nil nil pattern)
pattern (verilog-string-replace-matches "[?]" "." nil nil pattern)
pattern (concat "^" pattern "$")
dirfiles (verilog-dir-files root))
(while dirfiles
(setq basefile (car dirfiles)
dirfile (expand-file-name (concat root basefile rest))
dirfiles (cdr dirfiles))
(when (and (string-match pattern basefile)
;; Don't allow abc/*/rtl to match abc/rtl via ..
(not (equal basefile "."))
(not (equal basefile "..")))
;; Might have more wildcards, so process again
(setq dirnames (cons dirfile dirnames)))))
;; Defaults
(t
(if (file-directory-p dirname)
(setq dirlist (cons dirname dirlist))))))
dirlist)))