help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: c-mode and underscore


From: Xah Lee
Subject: Re: c-mode and underscore
Date: Wed, 8 Jul 2009 03:44:53 -0700 (PDT)
User-agent: G2/1.0

On Jul 7, 10:40 pm, Kevin Rodgers <address@hidden> wrote:
> Xah Lee wrote:
> > On Jul 7, 3:56 pm, geophile <address@hidden> wrote:
> >> I am trying to get c-mode to treat underscore as a word, so that
> >> forward-word backward-word don't stop on underscores.
>
> >> My .emacs file includes:
>
> >>     (modify-syntax-entry ?_ "w" c-mode-syntax-table)
>
> >> which does not appear to be effective. But if I run this command
> >> manually, it is effective.
>
> >> I'm pretty sure that the line above is being reached in my .emacs
> >> file, as later commands are effective.
>
> > your code mod the global syntax table. you want to mode the syntax
> > table for that mode. It works when u call manually because when u are
> > in that mode, it mods that mod's syntax table.
>
> How could c-mode-syntax-table refer to the current (not global) syntax
> table?
>
> > hook is a good solution.
>
> It is consistent with the hypothesis that the problem is that
> c-mode-syntax-table does not have its correct value when .emacs is
> loaded.  Indeed, this code from progmodes/cc-mode.el reveals why it
> is nil when .emacs is loaded and thus does refer to the current syntax
> table as you said:
>
> ;;;###autoload
> (defvar c-mode-syntax-table nil
>    "Syntax table used in c-mode buffers.")
> (or c-mode-syntax-table
>      (setq c-mode-syntax-table
>           (funcall (c-lang-const c-make-mode-syntax-table c))))
>
> The autoload cookie causes the defvar to be copied into loaddefs.el
> and thus dumped into the emacs executable.  Why does cc-mode.el do that
> instead of the obvious
>
> (defvar c-mode-syntax-table (funcall (c-lang-const
> c-make-mode-syntax-table c))
>    "Syntax table used in c-mode buffers.")
>
> > e.g.
>
> > (add-hook 'w3m-mode-hook
> >  (lambda ()
> >   (define-key w3m-mode-map (kbd "<up>") 'previous-line) ; was w3m-
> > previous-anchor. Use Shift+Tab.
> >   (define-key w3m-mode-map (kbd "<down>") 'next-line) ; was w3m-next-
> > anchor. Use Tab.
> >   (define-key w3m-mode-map (kbd "<left>") 'backward-char) ; was w3m-
> > view-previous-page. Use B.
> >   (define-key w3m-mode-map (kbd "<right>") 'forward-char) ; was w3m-
> > view-this-url. Use Enter.
> > ))
>
> > you want to find the syntax table name for that mode to modify.
>
> If you're going to use a hook, you may as well just refer to the current
> syntax table with (syntax-table) instead of by name.


Thanks Kevin. I was probably wrong. Don't know this issue well. Was
trying to give a quick direction towards the solution but i was
misleading.

 Xah


reply via email to

[Prev in Thread] Current Thread [Next in Thread]