emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH] Add support for C++ headers to `ffap'.


From: Rüdiger Sonderfeld
Subject: [PATCH] Add support for C++ headers to `ffap'.
Date: Thu, 19 Sep 2013 23:51 +0200
User-agent: KMail/4.10.5 (Linux/3.8.0-30-generic; KDE/4.10.5; x86_64; ; )

Using only `ffap-c-mode' does not work for C++ headers from
libstdc++.  Those headers are usually stored in
"/usr/include/c++/<version>/".

* lisp/ffap.el (ffap-c++-path): New variable.
(ffap-c++-mode): New function.
(ffap-alist): Use `ffap-c++-mode' for `c++-mode'.

Signed-off-by: Rüdiger Sonderfeld <address@hidden>
---
 lisp/ffap.el | 18 +++++++++++++++++-
 1 file changed, 17 insertions(+), 1 deletion(-)

diff --git a/lisp/ffap.el b/lisp/ffap.el
index 737de8b..14700ad 100644
--- a/lisp/ffap.el
+++ b/lisp/ffap.el
@@ -769,7 +769,7 @@ (defvar ffap-alist
     ;; (lisp-interaction-mode . ffap-el-mode) ; maybe
     (finder-mode . ffap-el-mode)       ; type {C-h p} and try it
     (help-mode . ffap-el-mode)         ; maybe useful
-    (c++-mode . ffap-c-mode)           ; search ffap-c-path
+    (c++-mode . ffap-c++-mode)         ; search ffap-c++-path
     (cc-mode . ffap-c-mode)            ; same
     ("\\.\\([chCH]\\|cc\\|hh\\)\\'" . ffap-c-mode) ; stdio.h
     (fortran-mode . ffap-fortran-mode) ; FORTRAN requested by MDB
@@ -866,6 +866,22 @@ (defvar ffap-c-path
 (defun ffap-c-mode (name)
   (ffap-locate-file name t ffap-c-path))
 
+(defvar ffap-c++-path
+  (let ((g++-version (with-temp-buffer
+                       (when (= 0 (ignore-errors
+                                    (call-process "g++" nil t nil "-v")))
+                         (goto-char (point-min))
+                         (when (re-search-forward "gcc version 
\\([[:digit:]]+.[[:digit:]]+.[[:digit:]]+\\)"
+                                                  nil 'noerror)
+                           (match-string 1))))))
+    (if g++-version
+        (cons (concat "/usr/include/c++/" g++-version) ffap-c-path)
+      ffap-c-path))
+  "List of directories to search for include files.")
+
+(defun ffap-c++-mode (name)
+  (ffap-locate-file name t ffap-c++-path))
+
 (defvar ffap-fortran-path '("../include" "/usr/include"))
 
 (defun ffap-fortran-mode (name)
-- 
1.8.4




reply via email to

[Prev in Thread] Current Thread [Next in Thread]