[PLUG] Emacs: Setting Line Length for .txt Files

Dale Snell ddsnell at frontier.com
Thu Mar 12 01:46:52 UTC 2015


On Wed, 11 Mar 2015 16:06:18 -0700 (PDT), in message
alpine.LNX.2.11.1503111604270.9435 at localhost, Rich Shepard wrote:

> On Wed, 11 Mar 2015, Dale Snell wrote:
> 
> > I have the following in my ~/.emacs.d/init.el file:
> > (add-hook 'text-mode-hook (lambda () (setq-default fill-column 66)))
> 
> > Hope this helps.
> 
> Dale,
> 
>    I'm sure it will. Did not have ~/.emacs.d/init.el, but now I do.

You didn't?  Do you perchance have a ~/.emacs file?  That's the
same thing as the init.el.  I like having the init file in
~/.emacs.d, since I can keep all of my Emacs stuff in the same
directory.

BTW, you might want to put this in your init file:

;;; Make text-mode the default major mode.
(setq-default major-mode 'text-mode)

As the comment says, it makes text-mode the default.  Another
thing you can do is turn on ruler-mode with M-x ruler-mode RET.
You can also do it in your init file:

;;; turn on the ruler mode.
(add-hook 'lisp-interaction-mode-hook 'ruler-mode)
(add-hook 'text-mode-hook 'ruler-mode)
(add-hook 'nroff-mode-hook 'ruler-mode)
;;; end of ruler-mode setup

Ruler mode puts a character ruler at the top of the window,
showing tab positions, comment column, and fill column.  You can
change the latter by grabbing it with the middle mouse button and
moving it wherever you want.

There's a number of other things you might like in your init file:

;;; if a file doesn't end with a newline, ask:
(setq require-final-newline 'query)

;;; Add user-only local storage for Emacs-Lisp packages
(let ((default-directory "~/.emacs.d/user-lisp/"))
  (normal-top-level-add-to-load-path '("."))
  (normal-top-level-add-subdirs-to-load-path)
)

;;; New in Emacs 24!  Electric-mode everywhere!  Oh.  Happy.  Joy.
;;; Turn it freaking OFF.  Grump.  Get offa my lawn, ya damn kids!
(setq electric-indent-mode nil)

;;; Keep Custom out of my init file!  Set the absolute path of an
;;; external file for Custom to scribble in, then tell Emacs to load it.
(setq custom-file "~/.emacs.d/custom-settings.el")
(load custom-file)

;;; Use ElectricBufferList; it works a bit nicer that the default.
(global-set-key (kbd "C-x C-b") 'electric-buffer-list)
;;
;; Set up font locking for the buffer menu list.
(setq buffer-menu-buffer-font-lock-keywords
  '(("^....[*]Man .*Man.*" . font-lock-variable-name-face) ; Man page
    (".*Dired.*"           . font-lock-comment-face)       ; Dired buffer
    ("^....[*]shell.*"     . font-lock-preprocessor-face)  ; shell buffer
    (".*[*]scratch[*].*"   . font-lock-function-name-face) ; scratch buffer
    ("^....[*].*"          . font-lock-string-face)        ; "*" named buffers
    ("^..[*].*"            . font-lock-constant-face)      ; Modified
    ("^.[%].*"             . font-lock-keyword-face)))     ; Read only
;;
(defun buffer-menu-custom-font-lock  ()
  (let ((font-lock-unfontify-region-function
         (lambda (start end)
           (remove-text-properties start end '(font-lock-face nil)))))
    (font-lock-unfontify-buffer)
    (set (make-local-variable 'font-lock-defaults)
         '(buffer-menu-buffer-font-lock-keywords t))
    (font-lock-fontify-buffer)))
;;
;; Use the first line if ElectricBufferList is enabled, otherwise, use the
;; second line (one line only!) for the default buffer list functionality.
(add-hook 'electric-buffer-menu-mode-hook 'buffer-menu-custom-font-lock)
;; (add-hook 'buffer-menu-mode-hook 'buffer-menu-custom-font-lock)
;;
;;; End of electric-buffer-list setup.


A note about the Custom setting, above.  "Custom" refers the Emacs
"Customize" facility.  You can change all sorts of things with it,
to configure Emacs the way you like it.  However, when you do so,
Emacs sticks a block of nigh-unreadable ELisp code at the end of
your init file.  The more you customize, the bigger the block
gets, and the less readable.  Giving Emacs a place to put it keeps
your init file smaller and neater.


Anyhoo, I've babbled at you enough.  Enjoy!

--Dale

-- 
Money is truthful.  If a man speaks of his honor, make him pay cash.
		-- Lazarus Long
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 473 bytes
Desc: OpenPGP digital signature
URL: <http://lists.pdxlinux.org/pipermail/plug/attachments/20150311/832b5a02/attachment.asc>


More information about the PLUG mailing list