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

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

Re: Setting truncate-lines based on file type (extension)


From: Kevin Rodgers
Subject: Re: Setting truncate-lines based on file type (extension)
Date: Thu, 01 Oct 2009 06:11:33 -0600
User-agent: Thunderbird 2.0.0.23 (Macintosh/20090812)

amicitas wrote:
On Sep 29, 11:00 pm, Kevin Rodgers <kevin.d.rodg...@gmail.com> wrote:
amicitas wrote:
For certain types of files I want to set truncate-lines to true.  I
would like to be able to specify these files based on the file
extension.  While I know how to set the mode, but how would I go about
changing settings?
(defun my-set-truncate-lines ()
   "Set `truncate-lines' to t when visiting a file whose extension is
\"ext1\", \"ext2\", or \"ext3\"."
   (when (member (file-name-extension buffer-file-name)
                '("ext1" "ext2" "ext3"))
     (setq truncate-lines t))
   ;; return value for find-file-not-found-hooks:
   nil)

(add-hook 'find-file-hook 'my-set-truncate-lines)
(add-hook 'find-file-not-found-functions 'my-set-truncate-lines)

Thank you Kevin.  That is precisely what I was looking for.

In my case I am using this to make viewing of certain types of data
and calibration files easier.   These files should be opened in 'text-
mode', except with out wrapping.  Setting a mode hook is therefore not
appropriate.  This seems like a better solution that creating (or
finding) a 'data-mode'.

I don't know: define-derived-mode makes it very easy to define your data-mode,
which would set truncate-lines directly.

Alternatively, there's no reason not to put the hook function on
text-mode-hook instead of find-file-hook and find-file-not-found-functions.

--
Kevin Rodgers
Denver, Colorado, USA





reply via email to

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