emacs-devel
[Top][All Lists]
Advanced

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

mode setting question


From: Thomas Lord
Subject: mode setting question
Date: Tue, 14 Jul 2009 13:27:09 -0700

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







reply via email to

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