* [PATCH] Add support for C++ headers to `ffap'.
@ 2013-09-19 21:51 Rüdiger Sonderfeld
2013-09-20 5:26 ` Thien-Thi Nguyen
2013-09-20 10:10 ` [PATCH 2] " Rüdiger Sonderfeld
0 siblings, 2 replies; 8+ messages in thread
From: Rüdiger Sonderfeld @ 2013-09-19 21:51 UTC (permalink / raw)
To: emacs-devel
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 <ruediger@c-plusplus.de>
---
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
^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [PATCH] Add support for C++ headers to `ffap'.
2013-09-19 21:51 [PATCH] Add support for C++ headers to `ffap' Rüdiger Sonderfeld
@ 2013-09-20 5:26 ` Thien-Thi Nguyen
2013-09-20 5:47 ` Kalle Olavi Niemitalo
2013-09-20 8:36 ` Rüdiger Sonderfeld
2013-09-20 10:10 ` [PATCH 2] " Rüdiger Sonderfeld
1 sibling, 2 replies; 8+ messages in thread
From: Thien-Thi Nguyen @ 2013-09-20 5:26 UTC (permalink / raw)
To: Rüdiger Sonderfeld; +Cc: emacs-devel
[-- Attachment #1: Type: text/plain, Size: 384 bytes --]
() Rüdiger Sonderfeld <ruediger@c-plusplus.de>
() Thu, 19 Sep 2013 23:51 +0200
+ (when (= 0 (ignore-errors ...)))
You can use ‘zerop’ here.
--
Thien-Thi Nguyen
GPG key: 4C807502
(if you're human and you know it)
read my lisp: (responsep (questions 'technical)
(not (via 'mailing-list)))
=> nil
[-- Attachment #2: Type: application/pgp-signature, Size: 197 bytes --]
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] Add support for C++ headers to `ffap'.
2013-09-20 5:26 ` Thien-Thi Nguyen
@ 2013-09-20 5:47 ` Kalle Olavi Niemitalo
2013-09-20 8:47 ` Andreas Schwab
2013-09-20 8:36 ` Rüdiger Sonderfeld
1 sibling, 1 reply; 8+ messages in thread
From: Kalle Olavi Niemitalo @ 2013-09-20 5:47 UTC (permalink / raw)
To: Thien-Thi Nguyen; +Cc: Rüdiger Sonderfeld, emacs-devel
Thien-Thi Nguyen <ttn@gnu.org> writes:
> () Rüdiger Sonderfeld <ruediger@c-plusplus.de>
> () Thu, 19 Sep 2013 23:51 +0200
>
> + (when (= 0 (ignore-errors ...)))
>
> You can use ‘zerop’ here.
If ignore-errors handles an error, it returns nil. Don't both
(= 0 nil) and (zerop nil) signal a wrong-type-argument error?
I.e. should this instead be (ignore-errors (zerop ...))?
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] Add support for C++ headers to `ffap'.
2013-09-20 5:47 ` Kalle Olavi Niemitalo
@ 2013-09-20 8:47 ` Andreas Schwab
0 siblings, 0 replies; 8+ messages in thread
From: Andreas Schwab @ 2013-09-20 8:47 UTC (permalink / raw)
To: Kalle Olavi Niemitalo
Cc: Rüdiger Sonderfeld, Thien-Thi Nguyen, emacs-devel
Kalle Olavi Niemitalo <kon@iki.fi> writes:
> Thien-Thi Nguyen <ttn@gnu.org> writes:
>
>> () Rüdiger Sonderfeld <ruediger@c-plusplus.de>
>> () Thu, 19 Sep 2013 23:51 +0200
>>
>> + (when (= 0 (ignore-errors ...)))
>>
>> You can use ‘zerop’ here.
>
> If ignore-errors handles an error, it returns nil. Don't both
> (= 0 nil) and (zerop nil) signal a wrong-type-argument error?
> I.e. should this instead be (ignore-errors (zerop ...))?
call-process can return a non-number as well.
Andreas.
--
Andreas Schwab, schwab@linux-m68k.org
GPG Key fingerprint = 58CA 54C7 6D53 942B 1756 01D3 44D5 214B 8276 4ED5
"And now for something completely different."
^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH] Add support for C++ headers to `ffap'.
2013-09-20 5:26 ` Thien-Thi Nguyen
2013-09-20 5:47 ` Kalle Olavi Niemitalo
@ 2013-09-20 8:36 ` Rüdiger Sonderfeld
2013-10-19 2:36 ` Glenn Morris
1 sibling, 1 reply; 8+ messages in thread
From: Rüdiger Sonderfeld @ 2013-09-20 8:36 UTC (permalink / raw)
To: Thien-Thi Nguyen; +Cc: emacs-devel
It should have been `eq' to handle `ignore-errors' returning nil in
case of error.
Regards,
Rüdiger
----- 8< ------------------------------- >8 -------------
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 <ruediger@c-plusplus.de>
---
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) ; 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,23 @@ (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 (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"))
(defun ffap-fortran-mode (name)
--
1.8.4
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH 2] Add support for C++ headers to `ffap'.
2013-09-19 21:51 [PATCH] Add support for C++ headers to `ffap' Rüdiger Sonderfeld
2013-09-20 5:26 ` Thien-Thi Nguyen
@ 2013-09-20 10:10 ` Rüdiger Sonderfeld
2013-09-30 22:11 ` Rüdiger Sonderfeld
1 sibling, 1 reply; 8+ messages in thread
From: Rüdiger Sonderfeld @ 2013-09-20 10:10 UTC (permalink / raw)
To: emacs-devel
This updated version also checks if GCC was configured with
`--with-gxx-include-dir='.
--- 8< ------------------------------------------------------------- >8 ---
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 <ruediger@c-plusplus.de>
---
lisp/ffap.el | 24 +++++++++++++++++++++++-
1 file changed, 23 insertions(+), 1 deletion(-)
diff --git a/lisp/ffap.el b/lisp/ffap.el
index 737de8b..79539a4 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,28 @@ (defvar ffap-c-path
(defun ffap-c-mode (name)
(ffap-locate-file name t ffap-c-path))
+(defvar ffap-c++-path
+ (let ((c++-include-dir (with-temp-buffer
+ (when (eq 0 (ignore-errors
+ (call-process "g++" nil t nil "-v")))
+ (goto-char (point-min))
+ (if (re-search-forward "--with-gxx-include-dir=\
+\\([^[:space:]]+\\)"
+ nil 'noerror)
+ (match-string 1)
+ (when (re-search-forward "gcc version \
+\\([[:digit:]]+.[[:digit:]]+.[[:digit:]]+\\)"
+ nil 'noerror)
+ (expand-file-name (match-string 1)
+ "/usr/include/c++/")))))))
+ (if c++-include-dir
+ (cons c++-include-dir 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
^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [PATCH 2] Add support for C++ headers to `ffap'.
2013-09-20 10:10 ` [PATCH 2] " Rüdiger Sonderfeld
@ 2013-09-30 22:11 ` Rüdiger Sonderfeld
0 siblings, 0 replies; 8+ messages in thread
From: Rüdiger Sonderfeld @ 2013-09-30 22:11 UTC (permalink / raw)
To: emacs-devel; +Cc: Thien-Thi Nguyen
*ping*
Any comment about the updated version?
Regards,
Rüdiger Sonderfeld
On Friday 20 September 2013 12:10:55 Rüdiger Sonderfeld wrote:
> This updated version also checks if GCC was configured with
> `--with-gxx-include-dir='.
>
> --- 8< ------------------------------------------------------------- >8 ---
>
> 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 <ruediger@c-plusplus.de>
> ---
> lisp/ffap.el | 24 +++++++++++++++++++++++-
> 1 file changed, 23 insertions(+), 1 deletion(-)
>
> diff --git a/lisp/ffap.el b/lisp/ffap.el
> index 737de8b..79539a4 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,28 @@ (defvar ffap-c-path
> (defun ffap-c-mode (name)
> (ffap-locate-file name t ffap-c-path))
>
> +(defvar ffap-c++-path
> + (let ((c++-include-dir (with-temp-buffer
> + (when (eq 0 (ignore-errors
> + (call-process "g++" nil t nil
> "-v"))) + (goto-char (point-min))
> + (if (re-search-forward
> "--with-gxx-include-dir=\ +\\([^[:space:]]+\\)"
> + nil 'noerror)
> + (match-string 1)
> + (when (re-search-forward "gcc version \
> +\\([[:digit:]]+.[[:digit:]]+.[[:digit:]]+\\)"
> + nil 'noerror)
> + (expand-file-name (match-string 1)
> +
> "/usr/include/c++/"))))))) + (if c++-include-dir
> + (cons c++-include-dir 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)
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2013-10-19 2:36 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-09-19 21:51 [PATCH] Add support for C++ headers to `ffap' Rüdiger Sonderfeld
2013-09-20 5:26 ` Thien-Thi Nguyen
2013-09-20 5:47 ` Kalle Olavi Niemitalo
2013-09-20 8:47 ` Andreas Schwab
2013-09-20 8:36 ` Rüdiger Sonderfeld
2013-10-19 2:36 ` Glenn Morris
2013-09-20 10:10 ` [PATCH 2] " Rüdiger Sonderfeld
2013-09-30 22:11 ` Rüdiger Sonderfeld
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).