all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: 3246251196ryan@gmail.com
To: help-gnu-emacs@gnu.org
Subject: Re: Emacs *-mode add-hook functions (not working>)
Date: Fri, 7 Nov 2014 09:21:49 -0800 (PST)	[thread overview]
Message-ID: <3db87751-023e-406b-a9b5-9fba4dfd34e7@googlegroups.com> (raw)
In-Reply-To: <mailman.13128.1415372413.1147.help-gnu-emacs@gnu.org>

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 =================================


      parent reply	other threads:[~2014-11-07 17:21 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-11-07 14:18 Emacs *-mode add-hook functions (not working>) 3246251196ryan
2014-11-07 14:59 ` Eli Zaretskii
2014-11-07 17:58   ` Stefan Monnier
     [not found]   ` <mailman.13162.1415383171.1147.help-gnu-emacs@gnu.org>
2014-11-09 23:15     ` 3246251196ryan
2014-11-10 15:49       ` 3246251196ryan
2014-11-10 17:37         ` 3246251196ryan
2014-11-10 18:39           ` Drew Adams
     [not found]           ` <mailman.13379.1415644798.1147.help-gnu-emacs@gnu.org>
2014-11-11 17:33             ` 3246251196ryan
     [not found] ` <mailman.13128.1415372413.1147.help-gnu-emacs@gnu.org>
2014-11-07 17:21   ` 3246251196ryan [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=3db87751-023e-406b-a9b5-9fba4dfd34e7@googlegroups.com \
    --to=3246251196ryan@gmail.com \
    --cc=help-gnu-emacs@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.