* How in .dir-locals.el make association between file extension and Emacs mode?
@ 2010-12-28 22:31 Oleksandr Gavenko
2011-01-04 7:40 ` Kevin Rodgers
0 siblings, 1 reply; 8+ messages in thread
From: Oleksandr Gavenko @ 2010-12-28 22:31 UTC (permalink / raw)
To: help-gnu-emacs
How in .dir-locals.el make association between file extension and Emacs
mode?
--
Best regards!
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: How in .dir-locals.el make association between file extension and Emacs mode?
2010-12-28 22:31 How in .dir-locals.el make association between file extension and Emacs mode? Oleksandr Gavenko
@ 2011-01-04 7:40 ` Kevin Rodgers
2011-01-04 12:48 ` Oleksandr Gavenko
[not found] ` <mailman.0.1294145359.16099.help-gnu-emacs@gnu.org>
0 siblings, 2 replies; 8+ messages in thread
From: Kevin Rodgers @ 2011-01-04 7:40 UTC (permalink / raw)
To: help-gnu-emacs
On 12/28/10 3:31 PM, Oleksandr Gavenko wrote:
> How in .dir-locals.el make association between file extension and Emacs mode?
The association between file name extensions and major modes is stored in the
auto-mode-alist variable, which is not a buffer local variable and thus not
suitable to be used as a file or directory variable.
That is an abstract argument against it, there is also a practical argument:
auto-mode-alist is a global variable that is consulted by set-auto-mode, which
is run by normal-mode before it calls hack-local-variables/
hack-dir-local-variables.
What do you want to do?
--
Kevin Rodgers
Denver, Colorado, USA
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: How in .dir-locals.el make association between file extension and Emacs mode?
2011-01-04 7:40 ` Kevin Rodgers
@ 2011-01-04 12:48 ` Oleksandr Gavenko
[not found] ` <mailman.0.1294145359.16099.help-gnu-emacs@gnu.org>
1 sibling, 0 replies; 8+ messages in thread
From: Oleksandr Gavenko @ 2011-01-04 12:48 UTC (permalink / raw)
To: help-gnu-emacs
04.01.2011 9:40, Kevin Rodgers пишет:
> On 12/28/10 3:31 PM, Oleksandr Gavenko wrote:
>> How in .dir-locals.el make association between file extension and
>> Emacs mode?
>
> The association between file name extensions and major modes is stored
> in the
> auto-mode-alist variable, which is not a buffer local variable and thus not
> suitable to be used as a file or directory variable.
>
> That is an abstract argument against it, there is also a practical
> argument:
>
> auto-mode-alist is a global variable that is consulted by set-auto-mode,
> which
> is run by normal-mode before it calls hack-local-variables/
> hack-dir-local-variables.
>
> What do you want to do?
>
I store collected my tips under same folder with .txt extension.
Every time when I create new .txt file I forget add:
-*- mode: outline; coding: utf-8; fill-column: 80 -*-
to header. There are nearly 120 files.
I can fix headers from time to time by script but this require
spending own time, so ugly.
I expect that Emacs already have mechanism to make this.
Per project configurations which provided by standard Emacs packages.
--
Any help welcome!
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: How in .dir-locals.el make association between file extension and Emacs mode?
[not found] ` <mailman.0.1294145359.16099.help-gnu-emacs@gnu.org>
@ 2011-01-04 23:11 ` Tim X
2011-01-09 23:12 ` Oleksandr Gavenko
[not found] ` <mailman.0.1294614772.18285.help-gnu-emacs@gnu.org>
0 siblings, 2 replies; 8+ messages in thread
From: Tim X @ 2011-01-04 23:11 UTC (permalink / raw)
To: help-gnu-emacs
Oleksandr Gavenko <gavenkoa@gmail.com> writes:
> 04.01.2011 9:40, Kevin Rodgers пишет:
>> On 12/28/10 3:31 PM, Oleksandr Gavenko wrote:
>>> How in .dir-locals.el make association between file extension and
>>> Emacs mode?
>>
>> The association between file name extensions and major modes is stored
>> in the
>> auto-mode-alist variable, which is not a buffer local variable and thus not
>> suitable to be used as a file or directory variable.
>>
>> That is an abstract argument against it, there is also a practical
>> argument:
>>
>> auto-mode-alist is a global variable that is consulted by set-auto-mode,
>> which
>> is run by normal-mode before it calls hack-local-variables/
>> hack-dir-local-variables.
>>
>> What do you want to do?
>>
> I store collected my tips under same folder with .txt extension.
>
> Every time when I create new .txt file I forget add:
>
> -*- mode: outline; coding: utf-8; fill-column: 80 -*-
>
> to header. There are nearly 120 files.
>
> I can fix headers from time to time by script but this require
> spending own time, so ugly.
>
> I expect that Emacs already have mechanism to make this.
> Per project configurations which provided by standard Emacs packages.
>
> --
My first comment would be that you should not need to have these headers
at all - at least not with a fairly recent version of emacs. I only need
these types of file headers for the unusual/special case. What you have
in yours looks like the common or standard setup.
1. You can add files with extension .txt to auto-file-alist so that all
*.txt files will start up with outline mode enabled. Eliminate need for
first setting in your header.
2. UTF-8 is rapidly becoming the default coding system for most systems.
Unless you have the need for an alternative coding system because of
special characters that are not well supported under utf-8, you probably
should set this as your system default. Emacs will use the default
platform coding system as its default. So, set your environment to utf-8
and eliminate the second option from your header.
3. You can set the fill column via the custom 8nterface and you can
enable filling (wrapping) from the options menu for all text modes. This
would eliminate the last of your header settings and you would no longer
need the header line at all.
Another alternative to the above is to just put these settings in your
.dir-local file and ensure only *.txt fiels live below that directory.
However, my recommendation for this specific case is that you start using
org-mode.
I notice you are already using outline mode for your tip/note files, so
you will already be familiar with much of org-mode (which is based on
outline), plus you get a lot of other really handy things.
By default, files with the extension of .org will be palced in org mode,
so you can just try it by opening a file with that extension. Org mode
is so extremely useful for keeping notes/tips I'm not even sure where to
start. Some of its benefits include
* Improved key bindings for cycling through outline levels etc
* Handy table editing support
* Quick capturing of information, with formatting and other bits
* Useful linking and hypertext support
* Support for wiki like markup
* Export to multiple output formats
plus much much more. Cannot recommend it highly enough.
Tim
--
tcross (at) rapttech dot com dot au
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: How in .dir-locals.el make association between file extension and Emacs mode?
2011-01-04 23:11 ` Tim X
@ 2011-01-09 23:12 ` Oleksandr Gavenko
[not found] ` <mailman.0.1294614772.18285.help-gnu-emacs@gnu.org>
1 sibling, 0 replies; 8+ messages in thread
From: Oleksandr Gavenko @ 2011-01-09 23:12 UTC (permalink / raw)
To: help-gnu-emacs
On 2011-01-05 1:11, Tim X wrote:
>> Oleksandr Gavenko<gavenkoa@gmail.com> writes:
>> I store collected my tips under same folder with .txt extension.
>>
>> Every time when I create new .txt file I forget add:
>>
>> -*- mode: outline; coding: utf-8; fill-column: 80 -*-
>>
>> to header. There are nearly 120 files.
>>
>> I can fix headers from time to time by script but this require
>> spending own time, so ugly.
>>
>> I expect that Emacs already have mechanism to make this.
>> Per project configurations which provided by standard Emacs packages.
>
> My first comment would be that you should not need to have these headers
> at all - at least not with a fairly recent version of emacs. I only need
> these types of file headers for the unusual/special case. What you have
> in yours looks like the common or standard setup.
>
Yes. I want eliminate them.
> 1. You can add files with extension .txt to auto-file-alist so that all
> *.txt files will start up with outline mode enabled. Eliminate need for
> first setting in your header.
>
I prefer save association for '*.txt' to 'text-mode'.
.txt files usually interpreted as text files by many software.
If I make own unique extension I must teach all another soft how
understand this files (if this is possible )).
> 2. UTF-8 is rapidly becoming the default coding system for most systems.
> Unless you have the need for an alternative coding system because of
> special characters that are not well supported under utf-8, you probably
> should set this as your system default. Emacs will use the default
> platform coding system as its default. So, set your environment to utf-8
> and eliminate the second option from your header.
>
Agree, but how about Russian Windows with it default cp1251?
> 3. You can set the fill column via the custom 8nterface and you can
> enable filling (wrapping) from the options menu for all text modes. This
> would eliminate the last of your header settings and you would no longer
> need the header line at all.
>
Set fill-column every time I edit new file is unnecessary work.
And I always forget which value I prefer 78 or 80 or 90 or 120?
As I store files under version control when run 'fill-region'
with different 'fill-column' I get changes in places where I do
not edit text.
> Another alternative to the above is to just put these settings in your
> .dir-local file and ensure only *.txt fiels live below that directory.
>
I understand how set 'fill-column' via '.dir-local.el'.
But how set coding system and make association between file extension
and Emacs modes?
> However, my recommendation for this specific case is that you start using
> org-mode.
>
> I notice you are already using outline mode for your tip/note files, so
> you will already be familiar with much of org-mode (which is based on
> outline), plus you get a lot of other really handy things.
>
> By default, files with the extension of .org will be palced in org mode,
> so you can just try it by opening a file with that extension. Org mode
> is so extremely useful for keeping notes/tips I'm not even sure where to
> start. Some of its benefits include
>
> * Improved key bindings for cycling through outline levels etc
> * Handy table editing support
> * Quick capturing of information, with formatting and other bits
> * Useful linking and hypertext support
> * Support for wiki like markup
> * Export to multiple output formats
>
>
> plus much much more. Cannot recommend it highly enough.
Thanks for interest and tips. I would try org-mode.
Currently I use 'outline-mode' for:
* colouring headers to make it more visible
* folding text to see document structure (only headers shown)
Sorry, but I repeat question:
How set coding system and make association between file extension
and Emacs modes per directory?
--
Best regards!
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: How in .dir-locals.el make association between file extension and Emacs mode?
[not found] ` <mailman.0.1294614772.18285.help-gnu-emacs@gnu.org>
@ 2011-01-10 0:00 ` Tim X
2011-01-10 18:23 ` Stefan Monnier
1 sibling, 0 replies; 8+ messages in thread
From: Tim X @ 2011-01-10 0:00 UTC (permalink / raw)
To: help-gnu-emacs
Oleksandr Gavenko <gavenkoa@gmail.com> writes:
> On 2011-01-05 1:11, Tim X wrote:
>>> Oleksandr Gavenko<gavenkoa@gmail.com> writes:
>>> I store collected my tips under same folder with .txt extension.
>>>
>>> Every time when I create new .txt file I forget add:
>>>
>>> -*- mode: outline; coding: utf-8; fill-column: 80 -*-
>>>
>>> to header. There are nearly 120 files.
>>>
>>> I can fix headers from time to time by script but this require
>>> spending own time, so ugly.
>>>
>>> I expect that Emacs already have mechanism to make this.
>>> Per project configurations which provided by standard Emacs packages.
>>
>> My first comment would be that you should not need to have these headers
>> at all - at least not with a fairly recent version of emacs. I only need
>> these types of file headers for the unusual/special case. What you have
>> in yours looks like the common or standard setup.
>>
> Yes. I want eliminate them.
>
>> 1. You can add files with extension .txt to auto-file-alist so that all
>> *.txt files will start up with outline mode enabled. Eliminate need for
>> first setting in your header.
>>
> I prefer save association for '*.txt' to 'text-mode'.
>
> .txt files usually interpreted as text files by many software.
>
> If I make own unique extension I must teach all another soft how
> understand this files (if this is possible )).
No, this would just happen within emacs - no other software would need
to know as yhou are only dealing with text. The setting would only
affect emacs when you opoen a *.txt file.
However, you have complete freedom. You can adopt a totally different
extension if you wanted. For example, by default org-mode, which is a
text based mode, uses the file extension .org. If you open a file with
the extension .org, emacs will load org-mode for that file. However, if
you then view the file with another program, such a notepad, it will
just look like normal text.
>
>> 2. UTF-8 is rapidly becoming the default coding system for most systems.
>> Unless you have the need for an alternative coding system because of
>> special characters that are not well supported under utf-8, you probably
>> should set this as your system default. Emacs will use the default
>> platform coding system as its default. So, set your environment to utf-8
>> and eliminate the second option from your header.
>>
> Agree, but how about Russian Windows with it default cp1251?
>
Not sure. Don't use windows and am not familiar with its weird coding
names.
>> 3. You can set the fill column via the custom 8nterface and you can
>> enable filling (wrapping) from the options menu for all text modes. This
>> would eliminate the last of your header settings and you would no longer
>> need the header line at all.
>>
> Set fill-column every time I edit new file is unnecessary work.
>
> And I always forget which value I prefer 78 or 80 or 90 or 120?
>
> As I store files under version control when run 'fill-region'
> with different 'fill-column' I get changes in places where I do
> not edit text.
>
No, you would not need to do this for every file you open. You set up a
default fill column and it is turned on for all files you open in
text-mode.
>> Another alternative to the above is to just put these settings in your
>> .dir-local file and ensure only *.txt fiels live below that directory.
>>
> I understand how set 'fill-column' via '.dir-local.el'.
>
> But how set coding system and make association between file extension
> and Emacs modes?
>
In dire-local file, the association is based on the mode of the file.
The mode the file opens in is determined by the file-mode-alist
settings. You cannot associate settings in .dir-local based on file
extensions directly.
>> However, my recommendation for this specific case is that you start using
>> org-mode.
>>
>> I notice you are already using outline mode for your tip/note files, so
>> you will already be familiar with much of org-mode (which is based on
>> outline), plus you get a lot of other really handy things.
>>
>> By default, files with the extension of .org will be palced in org mode,
>> so you can just try it by opening a file with that extension. Org mode
>> is so extremely useful for keeping notes/tips I'm not even sure where to
>> start. Some of its benefits include
>>
>> * Improved key bindings for cycling through outline levels etc
>> * Handy table editing support
>> * Quick capturing of information, with formatting and other bits
>> * Useful linking and hypertext support
>> * Support for wiki like markup
>> * Export to multiple output formats
>>
>>
>> plus much much more. Cannot recommend it highly enough.
> Thanks for interest and tips. I would try org-mode.
>
> Currently I use 'outline-mode' for:
>
> * colouring headers to make it more visible
> * folding text to see document structure (only headers shown)
>
Exactly what org-mode does, plus you get a lot of other functionality
you can use if you want. Org-mode is an extension/enhancement of outline
mode.
>
> Sorry, but I repeat question:
>
> How set coding system and make association between file extension
> and Emacs modes per directory?
You cannot. You can only make associations between emacs modes. However,
the mode a file is opened in is controlled by file-mode-alist.
As you are using .txt as your extension and the default file-mode-alist
for *.txt is text-mode, you would use that to define the associations
i.e.
((text-mode . ((file-column . 79)
(coding . utf-8)
(mode . outline))))
The above would set fill column to 79 and coding system to utf-8 for any
file inthe directory which is opened in text-mode.
The file-mode-alist associates *.txt with text-mode.
Therefore, any file opened in the directory that has an extension of
*.txt will be setup with folding at column 79 and a utf-8 coding system.
Tim
--
tcross (at) rapttech dot com dot au
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: How in .dir-locals.el make association between file extension and Emacs mode?
[not found] ` <mailman.0.1294614772.18285.help-gnu-emacs@gnu.org>
2011-01-10 0:00 ` Tim X
@ 2011-01-10 18:23 ` Stefan Monnier
2011-01-19 20:54 ` Ted Zlatanov
1 sibling, 1 reply; 8+ messages in thread
From: Stefan Monnier @ 2011-01-10 18:23 UTC (permalink / raw)
To: help-gnu-emacs
> I understand how set 'fill-column' via '.dir-local.el'.
> But how set coding system and make association between file extension
> and Emacs modes?
IIUC you want to have a "directory-local" setting for auto-mode-alist,
i.e. some way to specify that "files with name *.foo under this
directory should use bar-mode".
This sounds like an eminently reasonable request, and I don't think you
can do it with .dir-locals.el currently. So please M-x report-emacs-bug
and request this new feature.
Stefan
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: How in .dir-locals.el make association between file extension and Emacs mode?
2011-01-10 18:23 ` Stefan Monnier
@ 2011-01-19 20:54 ` Ted Zlatanov
0 siblings, 0 replies; 8+ messages in thread
From: Ted Zlatanov @ 2011-01-19 20:54 UTC (permalink / raw)
To: help-gnu-emacs
On Mon, 10 Jan 2011 13:23:43 -0500 Stefan Monnier <monnier@iro.umontreal.ca> wrote:
>> I understand how set 'fill-column' via '.dir-local.el'.
>> But how set coding system and make association between file extension
>> and Emacs modes?
SM> IIUC you want to have a "directory-local" setting for auto-mode-alist,
SM> i.e. some way to specify that "files with name *.foo under this
SM> directory should use bar-mode".
SM> This sounds like an eminently reasonable request, and I don't think you
SM> can do it with .dir-locals.el currently. So please M-x report-emacs-bug
SM> and request this new feature.
I don't think this has been done as you suggested, I don't see such a
bug opened.
Ted
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2011-01-19 20:54 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-12-28 22:31 How in .dir-locals.el make association between file extension and Emacs mode? Oleksandr Gavenko
2011-01-04 7:40 ` Kevin Rodgers
2011-01-04 12:48 ` Oleksandr Gavenko
[not found] ` <mailman.0.1294145359.16099.help-gnu-emacs@gnu.org>
2011-01-04 23:11 ` Tim X
2011-01-09 23:12 ` Oleksandr Gavenko
[not found] ` <mailman.0.1294614772.18285.help-gnu-emacs@gnu.org>
2011-01-10 0:00 ` Tim X
2011-01-10 18:23 ` Stefan Monnier
2011-01-19 20:54 ` Ted Zlatanov
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).