- assigned_to: nobody --> kpoxman
Small feature request. In my project I divide sources and headers, so I need extend function eassist-switch-h-cpp.
I am not professional in elisp. My version is:
;; Added by Andrew P. Falaleev
(defvar eassist-search-path '("../")
"List of search paths for headers and sources")
(defun eassist-switch-h-cpp ()
"Switch header and body file according to `eassist-header-switches' var.
The current buffer's file name extention is searched in
`eassist-header-switches' variable to find out extention for file's counterpart,
for example *.hpp <--> *.cpp."
(interactive)
(let* ((ext (file-name-extension (buffer-file-name)))
(base-name (eassist-string-without-last (file-name-nondirectory (buffer-file-name))
(length ext)))
(base-path (eassist-string-without-last
(eassist-string-without-last (buffer-file-name) (length ext))
(length base-name)))
(count-ext (cdr (find-if (lambda (i) (string= (car i) ext)) eassist-header-switches))))
(cond
(count-ext
(unless
(or
(loop for b in (mapcar (lambda (i) (concat base-name i)) count-ext)
when (bufferp (get-buffer b)) return (switch-to-buffer b))
;; (loop for c in (mapcar (lambda (i) (concat base-path base-name i)) count-ext)
(loop for c in (mapcar (lambda (j)
(mapcar (lambda (i)
(concat base-path i base-name j))
eassist-search-path))
count-ext)
do
(loop for b in c
when (file-exists-p b) return (find-file b))))
(message "There is no corresponding pair (header or body) file.")))
(t
(message "It is not a header or body file! See eassist-header-switches variable.")))))
May be you add my changes to the sources? This is more flexible for some situations.
Andrew.