For some reason emacs (GNU Emacs 22.2.1 (i486-pc-linux-gnu, X toolkit, Xaw3d scroll bars) of 2010-03-26 on rothera, modified by Ubuntu) on Ubuntu 9.10 has been spontaneously deciding to use MS-DOS/Windows line endings rather than Unix. This is rather wasteful of space, and sometimes causes issues with other tools. It's also inconvenient, since I was killing the emacs buffer, running dos2unix on the file, and then loading the fixed file back into emacs. Looking for a fix, I stumbled across three blog entries of note:
1) http://www.debianadmin.com/flip-convert-text-file-line-endings-between-unix-and-dos-formats.html recommends a tool called flip. This makes no sense to me whatsoever since it does exactly what dos2unix and unix2dos do. It looks to me like someone's CS1 assignment that somehow got added to the Debian repositories.
2) http://www.sowbug.org/mt/2004/07/emacs-dos-line-endings.html has a good short-term fix, a bit more convenient than what I was doing. Within emacs, type the following key sequence: C-x [ENTER] f unix [ENTER]. This sets the "Coding system for saving file." Good enough.
Also, Sowbug.org has a great tagline: "If all you have is a Bloom filter, everything looks like a set whose membership you wish to test with a possibility of false positives."
3) Barriehie at http://ubuntuforums.org/showthread.php?t=1375454 has the winner, a good, permanent, catch-all type solution. Essentially, modify .emacs to include:
;; Set ALL files to UNIX line endings
(add-hook 'find-file-hook 'find-file-check-line-endings)
(defun dos-file-endings-p ()
(string-match "dos" (symbol-name buffer-file-coding-system)))
(defun find-file-check-line-endings ()
(when (dos-file-endings-p)
(set-buffer-file-coding-system 'iso-latin-1-unix t)
(set-buffer-modified-p nil)))
I've tested it just a bit, and it works beautifully.
Also, my .emacs is all in one file, and I prefer the way he splits it across multiple files. I'm using the .emacs that grad students were given at Ohio State ca. 1992 with many, many modifications. Following Barriehie's lead, I've split my .emacs it into multiple files, thus allowing me to keep my modifications separate from the stuff passed down from Brutus Buckeye.
Showing posts with label windows. Show all posts
Showing posts with label windows. Show all posts
Thursday, June 3, 2010
Tuesday, September 2, 2008
GNU Emacs: making the obvious difficult
Off and on it's really irritated me that someone on the GNU team decided to change the default behavior of tab in fundamental mode from insert ^i to indent-relative. I hate indent-relative. It makes lining things up in columns in text files difficult. So every few months I do a Google search, find other people making the same complaint, and see less than helpful suggestions. Tonight I got more frustrated than usual, and so spent more time than usual. It appears that the following shuts off indent-relative for the most part without messing up filename completion or indentation in various modes, e.g., java or html.
(setq default-major-mode 'text-mode) (define-key text-mode-map "\t" "\C-q\C-i")The above is pretty much alpha code at the moment. There's detritus in my .emacs that suggests that years ago I didn't like text mode for pnews or mail modes, but those are no longer issues. indent-relative is, IMHO, evidence of word processor-oriented thought processes, not text editor-oriented processes. As Linux grows to be more Windows like (e.g., bloated and buggy), there seems to be an undercurrent of making basic tools, e.g., emacs and wc, less Unix-like.
Subscribe to:
Posts (Atom)