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: Mon, 10 Nov 2014 09:37:59 -0800 (PST)	[thread overview]
Message-ID: <538edd7a-8d2c-4d19-9edf-bb99871635df@googlegroups.com> (raw)
In-Reply-To: <2cd53f5b-d707-4362-b013-31afed98a96a@googlegroups.com>

On Monday, 10 November 2014 15:49:34 UTC, 3246251...@gmail.com  wrote:
> On Sunday, 9 November 2014 23:15:06 UTC, 3246251...@gmail.com  wrote:
> > I will test out whether or not the hook function gets called tomorrow.
> 
> Okay, the hook function is actually working which is strange. So the problem remains:
> 
> 
> That I must firstly open a C++ file in order to get CEDET to parse the headers. Once I do that I there is no problem opening up a .h file, it works. However, if I start emacs and firstly open a .h file I am forced to do M-x c-mode - but once that is done everything is fine thereafter.  
> 
> Just trying to figure out why this is the case.

To mark this as SOLVED:

I have got this working by including a simple clause in the function called on hook.

(if (string= "c-mode" major-mode)
  (progn
    (c++-mode))) ;; Switch C mode to C++ mode (because we use .h!)

Now things just work. I also forgot failed to realise how useful it is to switch to C++-mode when looking at a C++ .h file: the emacs colouring is all correct when in C++-mode, eg:

static void MyStatFunc(); 

the keyword were not being read correctly, so void would be the colour of the method name etc.

All good now with this hack, but still wondering why I needed to do M-x c-mode again in the first place to get things to run.


  reply	other threads:[~2014-11-10 17:37 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 [this message]
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

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=538edd7a-8d2c-4d19-9edf-bb99871635df@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.