From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: 3246251196ryan@gmail.com Newsgroups: gmane.emacs.help Subject: Re: Emacs *-mode add-hook functions (not working>) Date: Fri, 7 Nov 2014 09:21:49 -0800 (PST) Message-ID: <3db87751-023e-406b-a9b5-9fba4dfd34e7@googlegroups.com> References: NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 X-Trace: ger.gmane.org 1415381128 28227 80.91.229.3 (7 Nov 2014 17:25:28 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Fri, 7 Nov 2014 17:25:28 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Fri Nov 07 18:25:21 2014 Return-path: Envelope-to: geh-help-gnu-emacs@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 1XmnHk-0002ON-D3 for geh-help-gnu-emacs@m.gmane.org; Fri, 07 Nov 2014 18:25:20 +0100 Original-Received: from localhost ([::1]:33091 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XmnHj-0003u5-U5 for geh-help-gnu-emacs@m.gmane.org; Fri, 07 Nov 2014 12:25:19 -0500 X-Received: by 10.182.44.135 with SMTP id e7mr9359508obm.21.1415380909852; Fri, 07 Nov 2014 09:21:49 -0800 (PST) X-Received: by 10.140.91.118 with SMTP id y109mr205838qgd.3.1415380909822; Fri, 07 Nov 2014 09:21:49 -0800 (PST) Original-Path: usenet.stanford.edu!h15no7625307igd.0!news-out.google.com!u5ni26qab.1!nntp.google.com!u7no3140181qaz.1!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail Original-Newsgroups: gnu.emacs.help In-Reply-To: Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=194.39.218.10; posting-account=yK8oPQoAAAA1qIT_h_OI91dtN6mGEacV Original-NNTP-Posting-Host: 194.39.218.10 User-Agent: G2/1.0 Injection-Date: Fri, 07 Nov 2014 17:21:49 +0000 Original-Xref: usenet.stanford.edu gnu.emacs.help:208551 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:100829 Archived-At: On Friday, 7 November 2014 15:00:15 UTC, Eli Zaretskii wrote: > > Date: Fri, 7 Nov 2014 06:18:40 -0800 (PST) > > From: 3246251196ryan@gmail.com > > > > In order to use CEDET with Windows I need to tell semantic to append include files to search through to "the" list. In order to do this, I run a function on C++ mode. For example: > > > > === > > (add-hook 'c++-mode-hook 'rjd-my-semantic-load-includes) > > === > > > > ^^^^^ This is fine. When I load up a .cpp file the function is called and all the necessary headers are included and CEDET parses them. > > > > However, a few lines down I have this line: > > > > === > > (add-hook 'c-mode-hook 'rjd-my-semantic-load-includes) > > === > > > > At work we do not adhere to calling C++ include files with the .hpp file extension. Our header files are .h - thus, emacs considers this to be a C style. > > You could use c-mode-common-hook, then you wouldn't need 2 hooks. > > > When I open a .h file however I know the hook function has not been called (and I can prove it if you wish unless you are just happy to accept this). > > > > What am I doing wrong with these hook functions? > > I don't know. It works for me: visiting a .h file invokes a > c-mode-hook function. I think the answer is in your other > customizations. IOW, try this in "emacs -Q", and if it works then, > bisect your ~/.emacs to find the culprit. Thank you for your help but even with c-mode-common* the issue still remains. Once I run "M-x c-mode" everything is fine. =================MY EMACS========================= ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;; MODES ;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; MODE: CEDET (load-file "~/.emacs.d/cedet/cedet-devel-load.el") ;; This is the latest dev' version ~~ 26th Sept 2014 ;; Add further minor-modes to be enabled by semantic-mode. ;; See doc-string of `semantic-default-submodes' for other things ;; you can use here. (add-to-list 'semantic-default-submodes 'global-semantic-idle-summary-mode t) (add-to-list 'semantic-default-submodes 'global-semantic-idle-completions-mode t) (add-to-list 'semantic-default-submodes 'global-cedet-m3-minor-mode t) (semantic-mode 1) (global-ede-mode 1) (global-semantic-decoration-mode) ;; Deal with STL includes without .ext (C*-mode) (add-to-list 'magic-fallback-mode-alist '("^// " . c++-mode)) (add-to-list 'magic-fallback-mode-alist '("^#include" . c++-mode)) (add-to-list 'magic-fallback-mode-alist '("^// " . c-mode)) (add-to-list 'magic-fallback-mode-alist '("^#include" . c-mode)) ;; MODE: auto-complete (1.3.1) ;(add-to-list 'load-path "~/.emacs.d/autocomplete-mode") ;(require 'auto-complete-config) ;(add-to-list 'ac-dictionary-directories "~/.emacs.d/autocomplete-mode/ac-dict") ;(ac-config-default) ;; MODE: Global location of *.el (used for majority of "plugins") (setq load-path (append load-path (list "~/.emacs.d"))) ;; MODE: Load my version of compile.el (even though I have tried to byte-compile-file ;; it thinking it would pick up the new rjd function straight away! (TODO see why!) (load-file "~/Downloads/emacs-24.3-bin-i386/emacs-24.3/lisp/progmodes/compile.el") ;; MODE: My function for CEDET when EMACS opens C++ files (defun rjd-my-semantic-load-includes () "Have semantic CEDET try and understand which include paths to use" (if (string-match "RTEGen" buffer-file-name) (progn (setq my-base-dir (concat "d:/" ; d:/ "Work/" ; Work/ "RTE/" ; RTE/ (nth 3 (split-string default-directory "/")) "/" ; [[branch]]/ "RTEGen/" )) ; RTEGen/ (semantic-add-system-include (concat my-base-dir "A/")) (semantic-add-system-include (concat my-base-dir "C/")) (semantic-add-system-include (concat my-base-dir "DLLs/S/")) (semantic-add-system-include (concat my-base-dir "E/")) (semantic-add-system-include (concat my-base-dir "Er/")) (semantic-add-system-include (concat my-base-dir "F/")) (semantic-add-system-include (concat my-base-dir "I/")) (semantic-add-system-include (concat my-base-dir "Sh/")) (semantic-add-system-include (concat my-base-dir "M/")) (semantic-add-system-include (concat my-base-dir "TypesDB/")) (semantic-add-system-include (concat my-base-dir "RTEModel/")) (semantic-add-system-include "c:/Program Files (x86)/Microsoft Visual Studio 10.0/VC/include")) (progn (semantic-add-system-include "c:/MinGW/msys/1.0/include/c++/3.4.4"))) ;; Either way, include these! (semantic-add-system-include "d:/d/Ext/boost_1_46_1") (semantic-add-system-include "d:/d/Ext/xerces-c-3.1.1-x86-windows-vc-10.0/include")) ;; MODE: I want to run said function whenever I load a C++ file (related to above MODE) (add-hook 'c-mode-common-hook 'rjd-my-semantic-load-includes) ;; MODE: I want to run said function whenever I load a C++ file (related to above MODE) ;(add-hook 'c++-mode-hook 'rjd-my-semantic-load-includes) ;; MODE: We also have c files ;(add-hook 'c-mode-hook 'rjd-my-semantic-load-includes) ================== END MY EMACS =================================