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

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

Re: Is it possible directory local settings for file encoding?


From: Oleksandr Gavenko
Subject: Re: Is it possible directory local settings for file encoding?
Date: Thu, 06 Oct 2016 17:24:07 +0300
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.5 (gnu/linux)

On 2016-10-05, Eli Zaretskii wrote:
> You have file-coding-alist to match against file names, so why do you
> need the 'coding:' thing?
>
I didn't find ``file-coding-alist`` but ``file-coding-system-alist`` and it
satisfy my needs with:

   (add-to-list 'file-coding-system-alist '("\\.rst\\'" . prefer-utf-8-unix))

or may be better:

  (modify-coding-system-alist 'file "\\.rst\\'" 'prefer-utf-8-unix)

Also I found:

  auto-coding-alist is a variable defined in `mule.el'.

but it have precedence over `coding:' so less valuable for my purpose:

  The settings in this alist take priority over `coding:' tags
  in the file (see the function `set-auto-coding')
  and the contents of `file-coding-system-alist'.

================================================================

>> From: Oleksandr Gavenko <gavenkoa@gmail.com>
>> marker. Is it possible to use special keyword ``coding`` in
>> ``.dir-locals.el``?

Hm... I had in my ``.emacs``:

  (defun my--c++-header-file-p ()
    "Return non-nil, if in a C++ header."
    (and (string-match "\\.h$"
                       (or (buffer-file-name)
                           (buffer-name)))
         (save-excursion
           (re-search-forward "\\_<class\\_>" nil t))))

  (add-to-list 'magic-mode-alist '(my--c++-header-file-p . c++-mode))

Therefore coding system must be defined before buffer major mode
(``re-search-forward`` relay on buffer encoding).

So my original request is meaningless.

================================================================

What about per project settings for ``file-coding-system-alist``?

I mean that this settings is carried inside project hierarchy instead of
putting absolute paths or guessing prefixes in global ``~/.emacs``?

-- 
http://defun.work/




reply via email to

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