From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: =?ISO-8859-1?Q?R=FCdiger?= Sonderfeld Newsgroups: gmane.emacs.devel Subject: [PATCH] Add support for C++ headers to `ffap'. Date: Fri, 20 Sep 2013 10:36:08 +0200 Message-ID: <8118475.ycthmq3H9S@descartes> References: <87bo3o83nq.fsf@zigzag.favinet> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Trace: ger.gmane.org 1379666184 1008 80.91.229.3 (20 Sep 2013 08:36:24 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Fri, 20 Sep 2013 08:36:24 +0000 (UTC) Cc: emacs-devel@gnu.org To: Thien-Thi Nguyen Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Fri Sep 20 10:36:27 2013 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1VMwCQ-0003hT-IG for ged-emacs-devel@m.gmane.org; Fri, 20 Sep 2013 10:36:26 +0200 Original-Received: from localhost ([::1]:54656 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VMwCQ-000833-2r for ged-emacs-devel@m.gmane.org; Fri, 20 Sep 2013 04:36:26 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:33149) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VMwCH-0007ze-Gz for emacs-devel@gnu.org; Fri, 20 Sep 2013 04:36:23 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VMwCB-0002fY-I8 for emacs-devel@gnu.org; Fri, 20 Sep 2013 04:36:17 -0400 Original-Received: from ptmx.org ([178.63.28.110]:43769) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VMwCB-0002fU-Bi; Fri, 20 Sep 2013 04:36:11 -0400 Original-Received: from localhost (localhost [127.0.0.1]) by ptmx.org (Postfix) with ESMTP id BB6142A8F9; Fri, 20 Sep 2013 10:36:10 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at ptmx.org Original-Received: from ptmx.org ([127.0.0.1]) by localhost (ptmx.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id UEa5ZtAV-HRu; Fri, 20 Sep 2013 10:36:09 +0200 (CEST) Original-Received: from descartes.localnet (chello080108246092.7.14.vie.surfer.at [80.108.246.92]) by ptmx.org (Postfix) with ESMTPSA id 328A32A68E; Fri, 20 Sep 2013 10:36:08 +0200 (CEST) User-Agent: KMail/4.10.5 (Linux/3.8.0-30-generic; KDE/4.10.5; x86_64; ; ) In-Reply-To: <87bo3o83nq.fsf@zigzag.favinet> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-Received-From: 178.63.28.110 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:163502 Archived-At: It should have been `eq' to handle `ignore-errors' returning nil in case of error. Regards, R=C3=BCdiger ----- 8< ------------------------------- >8 ------------- Using only `ffap-c-mode' does not work for C++ headers from libstdc++. Those headers are usually stored in "/usr/include/c++//". * 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=C3=BCdiger Sonderfeld --- lisp/ffap.el | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/lisp/ffap.el b/lisp/ffap.el index 737de8b..d11c79c 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)=09; type {C-h p} and try it (help-mode . ffap-el-mode)=09=09; maybe useful - (c++-mode . ffap-c-mode)=09=09; search ffap-c-path + (c++-mode . ffap-c++-mode)=09=09; search ffap-c++-path (cc-mode . ffap-c-mode)=09=09; same ("\\.\\([chCH]\\|cc\\|hh\\)\\'" . ffap-c-mode) ; stdio.h (fortran-mode . ffap-fortran-mode)=09; FORTRAN requested by MDB @@ -866,6 +866,23 @@ (defvar ffap-c-path (defun ffap-c-mode (name) (ffap-locate-file name t ffap-c-path)) =20 +(defvar ffap-c++-path + (let ((g++-version (with-temp-buffer + (when (eq 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")) =20 (defun ffap-fortran-mode (name) --=20 1.8.4