From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Emanuel Berg Newsgroups: gmane.emacs.help Subject: Re: make buffer be c++ mode? Date: Sun, 24 May 2015 01:27:30 +0200 Organization: Aioe.org NNTP Server Message-ID: <87bnhazxgd.fsf@debian.uxu> References: NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1432423825 5518 80.91.229.3 (23 May 2015 23:30:25 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sat, 23 May 2015 23:30:25 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Sun May 24 01:30:20 2015 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 1YwIry-0004jP-WB for geh-help-gnu-emacs@m.gmane.org; Sun, 24 May 2015 01:30:19 +0200 Original-Received: from localhost ([::1]:38857 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YwIrx-0003tG-IX for geh-help-gnu-emacs@m.gmane.org; Sat, 23 May 2015 19:30:17 -0400 Original-Path: usenet.stanford.edu!news.kjsl.com!feeder.erje.net!1.eu.feeder.erje.net!news2.arglkargh.de!news.mixmin.net!aioe.org!.POSTED!not-for-mail Original-Newsgroups: gnu.emacs.help Original-Lines: 47 Original-NNTP-Posting-Host: feB02bRejf23rfBm51Mt7Q.user.speranza.aioe.org Original-X-Complaints-To: abuse@aioe.org User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.4 (gnu/linux) X-Notice: Filtered by postfilter v. 0.8.2 Cancel-Lock: sha1:apvp+r1CUu/kNkS/eVJER0m/U3E= Mail-Copies-To: never Original-Xref: usenet.stanford.edu gnu.emacs.help:212256 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:104540 Archived-At: Jai Dayal writes: > I have a file that I've opened with a .cu extension. > It's C++ code written for Cuda. How do I force Emacs > to display the buffer as if it were C mode? I just > want to do it just for this buffer. If you want this for this particular file and none other, do like this: (setq magic-mode-alist '(("/\\* cpp \\*/" . c++-mode))) Then write /* cpp */ first line in your .cu file. If you want this for any file with a .cu extension, you can do it like this - here I paste my code, you insert your data (.cu and c++-mode) the same way: (let ((extras '( ("\\.gpi" . gnuplot-mode) ("\\.\\(glsl\\|oil\\|ssc\\|dfy\\)" . c-mode) ("\\.lua" . lua-mode) ("\\.\\(service\\|list\\|theme\\|mailrc\\|sed\\|inc\\)" . conf-mode) ("\\.pic" . nroff-mode) ("\\.xr" . conf-xdefaults-mode) ("inputrc" . conf-colon-mode) ("KILL" . emacs-lisp-mode) ("\\.service" . emacs) ))) (setq auto-mode-alist (append extras auto-mode-alist)) ) As you see, I put a lot of files with goofy extensions into either C mode or configuration mode. The reason isn't those files are "really" C, rather C has a very basic syntax which is reused (or closely so) in a lot of languages. If you were to do that stuff every day (God forbid) then you'd want I proper mode, here it is just to make it look good and perhaps get some indentation as a quick fix the few times you do it. -- underground experts united http://user.it.uu.se/~embe8573