all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Thomas Lord <lord@emf.net>
To: emacs-devel <emacs-devel@gnu.org>
Subject: mode setting question
Date: Tue, 14 Jul 2009 13:27:09 -0700	[thread overview]
Message-ID: <1247603229.5941.25.camel@dell-desktop.example.com> (raw)

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	other threads:[~2009-07-14 20:27 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-07-14 20:27 Thomas Lord [this message]
2009-07-14 20:50 ` mode setting question Lennart Borgman
2009-07-15  0:47   ` Stefan Monnier

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1247603229.5941.25.camel@dell-desktop.example.com \
    --to=lord@emf.net \
    --cc=emacs-devel@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.