From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Kevin Rodgers Newsgroups: gmane.emacs.help Subject: Re: c-mode and underscore Date: Tue, 07 Jul 2009 23:40:09 -0600 Message-ID: References: <9168430a-e1d0-4f6c-8b4f-4eae95e4b239@h2g2000yqg.googlegroups.com> <03ed2840-29a9-4ee2-95f4-df57bcd2e985@z4g2000prh.googlegroups.com> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Trace: ger.gmane.org 1247031684 19725 80.91.229.12 (8 Jul 2009 05:41:24 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Wed, 8 Jul 2009 05:41:24 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Wed Jul 08 07:41:17 2009 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1MOPu9-0006Kq-DH for geh-help-gnu-emacs@m.gmane.org; Wed, 08 Jul 2009 07:41:17 +0200 Original-Received: from localhost ([127.0.0.1]:33188 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1MOPu8-0007WT-Ge for geh-help-gnu-emacs@m.gmane.org; Wed, 08 Jul 2009 01:41:16 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1MOPtM-0007Uk-R7 for help-gnu-emacs@gnu.org; Wed, 08 Jul 2009 01:40:28 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1MOPtG-0007Pl-5z for help-gnu-emacs@gnu.org; Wed, 08 Jul 2009 01:40:26 -0400 Original-Received: from [199.232.76.173] (port=51834 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1MOPtF-0007PT-NZ for help-gnu-emacs@gnu.org; Wed, 08 Jul 2009 01:40:21 -0400 Original-Received: from main.gmane.org ([80.91.229.2]:55544 helo=ciao.gmane.org) by monty-python.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1MOPtF-0007WX-56 for help-gnu-emacs@gnu.org; Wed, 08 Jul 2009 01:40:21 -0400 Original-Received: from list by ciao.gmane.org with local (Exim 4.43) id 1MOPtD-00010B-Q2 for help-gnu-emacs@gnu.org; Wed, 08 Jul 2009 05:40:19 +0000 Original-Received: from c-67-190-36-32.hsd1.co.comcast.net ([67.190.36.32]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Wed, 08 Jul 2009 05:40:19 +0000 Original-Received: from kevin.d.rodgers by c-67-190-36-32.hsd1.co.comcast.net with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Wed, 08 Jul 2009 05:40:19 +0000 X-Injected-Via-Gmane: http://gmane.org/ Original-Lines: 67 Original-X-Complaints-To: usenet@ger.gmane.org X-Gmane-NNTP-Posting-Host: c-67-190-36-32.hsd1.co.comcast.net User-Agent: Thunderbird 2.0.0.22 (Macintosh/20090605) In-Reply-To: <03ed2840-29a9-4ee2-95f4-df57bcd2e985@z4g2000prh.googlegroups.com> X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6, seldom 2.4 (older, 4) X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:65829 Archived-At: Xah Lee wrote: > On Jul 7, 3:56 pm, geophile 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 "") 'previous-line) ; was w3m- > previous-anchor. Use Shift+Tab. > (define-key w3m-mode-map (kbd "") 'next-line) ; was w3m-next- > anchor. Use Tab. > (define-key w3m-mode-map (kbd "") 'backward-char) ; was w3m- > view-previous-page. Use B. > (define-key w3m-mode-map (kbd "") '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. -- Kevin Rodgers Denver, Colorado, USA