help-gnu-emacs
[Top][All Lists]
Advanced

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

Re: How in .dir-locals.el make association between file extension and Em


From: Tim X
Subject: Re: How in .dir-locals.el make association between file extension and Emacs mode?
Date: Wed, 05 Jan 2011 10:11:14 +1100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.0.50 (gnu/linux)

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


reply via email to

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