Hi, all.

I have change the implementation of the eassist-switch-h-cpp to suit my requirement better.
In my case, the .h file and .cpp are often located in different locations. So the original  eassist-switch-h-cpp usually gave me a error message, which is frustrating.
I've changed it to use ido-find-file to give user a chance to specify the location of the counterpair.

Here is the change:
(require 'ido)

(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 (buffer-name) (length ext)))
         (base-path (eassist-string-without-last (buffer-file-name) (length ext)))
         (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
  (if (get-buffer-window b)
      (switch-to-buffer-other-window b)
    (if (get-buffer-window b t)
        (switch-to-buffer-other-frame b)
      (switch-to-buffer b))))
           (loop for c in (mapcar (lambda (count-ext) (concat base-path count-ext)) count-ext)
                 when (file-exists-p c) return (find-file c))
  (let ((dir (ido-read-file-name "Counterpair dir: ")))
    (loop for c in (mapcar 
    (lambda (ext)
      (concat dir "/" base-name ext))
    count-ext)
  when (file-exists-p c) return (find-file c))))
        (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.")))))

The code in red is the modification.

--
Best regards,
Yaolong Huang(Curtis)

Briontech China

Blog: http://blog.csdn.net/airekans/