From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Thomas Lord Newsgroups: gmane.emacs.devel Subject: mode setting question Date: Tue, 14 Jul 2009 13:27:09 -0700 Message-ID: <1247603229.5941.25.camel@dell-desktop.example.com> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain Content-Transfer-Encoding: 7bit X-Trace: ger.gmane.org 1247603251 27114 80.91.229.12 (14 Jul 2009 20:27:31 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Tue, 14 Jul 2009 20:27:31 +0000 (UTC) To: emacs-devel Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Tue Jul 14 22:27:24 2009 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1MQoax-0007Sy-Es for ged-emacs-devel@m.gmane.org; Tue, 14 Jul 2009 22:27:24 +0200 Original-Received: from localhost ([127.0.0.1]:38318 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1MQoaw-0007gK-Mn for ged-emacs-devel@m.gmane.org; Tue, 14 Jul 2009 16:27:22 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1MQoaq-0007a6-SI for emacs-devel@gnu.org; Tue, 14 Jul 2009 16:27:16 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1MQoam-0007Oj-3j for emacs-devel@gnu.org; Tue, 14 Jul 2009 16:27:16 -0400 Original-Received: from [199.232.76.173] (port=40941 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1MQoal-0007OM-Uw for emacs-devel@gnu.org; Tue, 14 Jul 2009 16:27:11 -0400 Original-Received: from smtp141.iad.emailsrvr.com ([207.97.245.141]:54967) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1MQoal-0006Jo-KF for emacs-devel@gnu.org; Tue, 14 Jul 2009 16:27:11 -0400 Original-Received: from relay24.relay.iad.mlsrvr.com (localhost [127.0.0.1]) by relay24.relay.iad.mlsrvr.com (SMTP Server) with ESMTP id A51111B4099; Tue, 14 Jul 2009 16:27:10 -0400 (EDT) Original-Received: by relay24.relay.iad.mlsrvr.com (Authenticated sender: lord-AT-emf.net) with ESMTPSA id 31B151B4093; Tue, 14 Jul 2009 16:27:10 -0400 (EDT) X-Mailer: Evolution 2.22.3.1 X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.4-2.6 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:112470 Archived-At: I am having some trouble puzzling out how to properly set the mode of a newly created buffer in a certain case. The function NORMAL-MODE doesn't appear to be what I want. Can someone please give me some guidance for this case: My program has created a new buffer with a strange name. The appropriate mode is not directly implied by the buffer name. There is no visited file for this buffer. So there is no visited file name. The buffer contents have been initialized by a CALL-PROCESS application. The contents might have auto-mode stuff at the top or bottom of the file. I have a variable, call it MY-NOMINAL-FILE-NAME which might be bound to something like "hw.c". There is no real, local file called "hw.c" but I know that this new buffer is conceptually open to a file named "hw.c". I would like to set the mode AS IF the visited file name were "hw.c", without that actually being the visited file name. That is, if the contents include automode foo within the buffer, use that. If not, consult the auto-mode-alist using hw.c and use that. What is the clean way to do so? An "unclean" way would be to, within an unwind protect, temporarily set the visited file name as a fiction, then call NORMAL-MODE, then eliminate the visited file name. Yet, I fret that the arbitrary code the mode function runs might do something "bad" on the false assumption that temporary visited file name is true. (If the question is ill-formed, betraying some deeper misunderstanding, please let me know that instead.) Thanks, -t