I'm a bit wary of adding ido dependencies into someone's code, as I'm
not familiar with ido, or eassist really.
If I understand what this bit of code is doing, it seems likely that EDE
could be asked, via ede-expand-file-name, to see if it can find the file
in the current project. Something vaguely like:
(when (ede-toplevel) (ede-expand-filename (ede-toplevel) myfilename))
EDE can often be good at finding headers, particularly if you enable
some of the EDE location systems. That might make it unnecessary to
query for the header at all.
I'm not familiar with ido, but if IDO mode is able to take over
different features in Emacs, it would be good to use the something that
IDO takes over for the querying part of eassist so as to not surprise
people that don't use ido. Is that possible?
On 09/28/2012 02:36 AM, Huang Yaolong wrote:
> 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
> for example *.hpp <--> *.cpp."
> (let* ((ext (file-name-extension (buffer-file-name)))
> (base-name (eassist-string-without-last (buffer-name) (length
> (base-path (eassist-string-without-last (buffer-file-name)
> (length ext)))
> (count-ext (cdr (find-if (lambda (i) (string= (car i) ext))
> (loop for b in (mapcar (lambda (i) (concat base-name i))
> 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.")))
> (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/
> Got visibility?
> Most devs has no idea what their production app looks like.
> Find out how fast your code is with AppDynamics Lite.
> Cedet-devel mailing list