all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* mode setting question
@ 2009-07-14 20:27 Thomas Lord
  2009-07-14 20:50 ` Lennart Borgman
  0 siblings, 1 reply; 3+ messages in thread
From: Thomas Lord @ 2009-07-14 20:27 UTC (permalink / raw)
  To: emacs-devel

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







^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2009-07-15  0:47 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-07-14 20:27 mode setting question Thomas Lord
2009-07-14 20:50 ` Lennart Borgman
2009-07-15  0:47   ` Stefan Monnier

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.