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

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

Re: any Emacs features to help keep code/comments under 80 columns width


From: ken
Subject: Re: any Emacs features to help keep code/comments under 80 columns width? (fwd)
Date: Sat, 21 Dec 2002 20:38:23 -0500 (EST)

This person needs help in a couple of ways.  The first is that stated in
the Subject line and noted below.  The second is that he can no longer
post to this list.  (I don't know if he can receive or not, so please cc
him.)


Thanks,
ken

---------- Forwarded message ----------
Date: Fri, 20 Dec 2002 11:56:37 -0800
From: seberino@spawar.navy.mil
To: ken@cleveland.lug.net
Subject: Re: any Emacs features to help keep code/comments under 80 columns
    width?

Ken

Thanks for the help.
By trial and error I found the item in my .emacs that
messes up (setq scroll-step 1) in .emacs.  I have
an item on my modeline that needs to updated often
so I added a "force-mode-line-update" (See below.).

When I don't include this line all if fine with scrolling.

Is there a way to get *both* working??

Chris

   (setq default-mode-line-format
      (list ""
            'mode-line-buffer-identification
            "     "
            (system-name)
            "     "
            "Line %l Column "
            '(:eval (format "%d" (1+ (current-column))))))
   (add-hook 'post-command-hook (lambda () (force-mode-line-update)))





On Fri, Dec 20, 2002 at 10:48:33AM -0500, ken@cleveland.lug.net wrote:
> 
> Chris,
> 
> Sorry that it's taken me awhile to respond.  I've had a lot to do and a 
> lot of email (~300) have collected in my email box.  I'm still working 
> on this.
> 
> To find out if there's something in your .emacs messing things up, start 
> emacs like so: "emacs -q".  This will load it without looking at .emacs.
> 
> Alternatively, you could save off your .emacs file to a different name; 
> this way you could experiment with different .emacs files.
> 
> Here's some things I have in my .emacs which do the things you want to 
> do:
> 
> ;; turn on auto-fill for text mode only.  Won't affect c-mode & others
> (add-hook 'text-mode-hook 'turn-on-auto-fill)
> (setq-default fill-column 78)
> 
> The above will work only when your in text-mode, That is, only when the 
> bar below the buffer you're in says "(Text ..." in it.  Modes in emacs 
> are nice once you get a handle on the concept.
> 
> About scrolling: 
> ;force Emacs to scroll only one line when I move past the bottom of the 
> ;screen:
> (setq scroll-step 1)
> 
> However, if you have a long line that wraps within emacs-- occupying two 
> or more lines onscreen-- emacs  will still treat that as a single line.  
> Insert CRs appropriately into such a line so that emacs doesn't wrap 
> them (showing the '\' character at the end of the line), and scrolling 
> should be smooth as expected.
> 
> 
> I think that covers everything you've asked.
> 
> You do have quite a bit in your .emacs file.  You're almost to the point 
> where you could write your own editor.  :)
> 
> 
> Hope I've helped,
> ken
> 
> seberino@spawar.navy.mil at 14:55 (UTC-0800) on Wed, 18 Dec 2002 said:
> 
> = Ken
> = 
> = I'd love to respond to your reply to my Emacs question
> = on help-gnu-emacs@gnu.org list but for some reason
> = I can't seem to send an email to that list anymore.
> = 
> = Can I ask you a question regarding your response???
> = 
> = I can turn on auto-fill-mode inside of Emacs but
> = _not_ from .emacs!!  This is what I added in .emacs...
> = 
> = (setq-default fill-column 80)
> = (add-hook 'text-mode-hook 'turn-on-auto-fill)
> = 
> = What would mess this up? Is there something else in .emacs
> = that would override these settings?
> = 
> = On a related note, I cannot seem to make scrolling with
> = down arrow only move text 1 line at a time.  All docs say
> = to do /this/ and I did it but it doesn't seem to work...
> = 
> = (setq scroll-step            1)
> = (setq scroll-conservatively 4)
> = 
> = I tried keeping/omitting each.
> = The text wants to still jump by half screens and move
> = cursor to middle of the screen all the time.
> = Is there something I'm missing or something in .emacs
> = that would negate these settings???
> = 
> = Thanks,
> = 
> = Chris
> = 
> = P.S. My .emacs has nothing weird or complicated in it.  Here it
> = is if you care to take a peek...
> = 
> = ; Default-Frame-AList
> = 
> =    (setq default-frame-alist
> =       '((font . "-b&h-luxi mono-medium-r-normal-*-*-160-*-*-m-*-iso8859-15")
> =         (background-color . "black")
> =         (foreground-color . "khaki")
> =         (cursor-color     . "red"  )))
> = 
> = ; Modeline
> = 
> =    (setq default-mode-line-format
> =       (list ""
> =             'mode-line-buffer-identification
> =             "     "
> =             (system-name)
> =             "     "
> =             "Line %l Column "
> =             '(:eval (format "%d" (1+ (current-column))))))
> =    (set-face-background 'modeline "red"  )
> =    (set-face-foreground 'modeline "black")
> =    (setq line-number-display-limit 10000000)
> =    (add-hook 'post-command-hook (lambda () (force-mode-line-update)))
> = 
> = ; Source Code
> = 
> =    (setq auto-mode-alist
> =       '(("\\.c\\'"    . cs-c-mode)
> =         ("\\.cpp\\'"  . cs-c-mode)
> =         ("\\.java\\'" . cs-c-mode)
> =         ("\\.h\\'"    . cs-c-mode)))
> =    (defun cs-c-mode()
> =       (c-mode)
> =       (c-set-style "K&R")
> =       (setq c-basic-offset 3)
> =       (turn-on-font-lock)
> =       (local-set-key "\C-d" 'cs-kill-line))
> = 
> = ; Deletions
> = 
> =    (menu-bar-mode             nil)
> =    (scroll-bar-mode           nil)
> =    (tool-bar-mode             nil)
> =    (setq auto-save-default    nil)
> =    (setq make-backup-files    nil)
> =    (setq suggest-key-bindings nil)
> = 
> = ; Miscellaneous
> = 
> =    (setq pop-up-frames          t)
> =    ;(setq scroll-step            1)
> = ;(setq scroll-conservatively 4)
> = (setq-default fill-column 80)
> = (add-hook 'text-mode-hook 'turn-on-auto-fill)
> =    (setq next-line-add-newlines nil)
> =    (setq require-final-newline  t)
> =    (set-face-background 'region "red")
> =    (set-face-foreground 'region "black")
> = 
> = ; Keys
> = 
> = (global-set-key   [delete] 'delete-backward-char)
> = (global-unset-key "\C-a")
> = (global-set-key   "\C-b"   'cs-search-backward)
> = (global-set-key   "\C-c"   'kill-ring-save)
> = (global-set-key   "\C-d"   'cs-kill-line)
> = (global-set-key   "\C-e"   'call-last-kbd-macro)
> = (global-set-key   "\C-f"   'cs-search-forward)
> = (global-set-key   "\C-g"   'goto-line)
> = (global-set-key   "\C-h"   'delete-backward-char)
> = (global-set-key   "\C-ai"  'insert-file)
> = (global-set-key   "\C-j"   'next-error)
> = (global-set-key   "\C-k"   'keyboard-escape-quit)
> = (global-set-key   "\C-am"  'cs-start-kbd-macro)
> = (global-set-key   "\C-n"   'cs2-search-forward)
> = (global-set-key   "\C-o"   'execute-extended-command)
> = (global-set-key   "\C-p"   'cs-yank)
> = (global-set-key   "\C-q"   'cs-kill-emacs)
> = (global-set-key   "\C-r"   'cs-replace-string)
> = (global-set-key   "\C-s"   'save-buffer)
> = (global-set-key   "\C-t"   'find-file-other-frame)
> = (global-set-key   "\C-u"   'undo)
> = (global-set-key   "\C-v"   'yank)
> = (global-set-key   "\C-w"   'cs-save-buffers-kill-emacs)
> = (global-set-key   "\C-x"   'kill-region)
> = (global-set-key   "\C-z"   'cs-compile)
> = 
> = ; Functions
> = 
> = (defun cs-compile() (interactive)
> =    (compile "make"))
> = 
> = (defun cs-kill-emacs() (interactive)
> =    (set-buffer-modified-p nil)
> =    (kill-buffer nil)
> =    (kill-emacs))
> = 
> = (defun cs-kill-line(&optional arg) (interactive "P")
> =    (let ((original-pos (point)))
> =       (kill-region (line-beginning-position) 
> =                    (min (+ (line-end-position arg) 1) (point-max))) 
> =       (goto-char (min original-pos (line-end-position)))))
> = 
> = (defun cs-replace-string(search-string replace-string) 
> =    (interactive "ssearch string: \nsreplace string: ")
> =    (save-excursion
> =       (goto-char 1)
> =       (while (search-forward search-string nil t)
> =          (replace-match replace-string nil t))))
> = 
> = (defun cs-save-buffers-kill-emacs() (interactive)
> =    (save-buffers-kill-emacs "y"))
> = 
> = (setq last-search-string  nil)
> = (setq last-search-forward t  )
> = 
> = (defun cs-search-backward(search-string) (interactive "ssearch string: ")
> =    (setq last-search-string  search-string)
> =    (setq last-search-forward nil)
> =    (search-backward search-string))
> = 
> = (defun cs-search-forward(search-string) (interactive "ssearch string: ")
> =    (setq last-search-string  search-string)
> =    (setq last-search-forward t)
> =    (search-forward search-string))
> = 
> = (defun cs2-search-forward() (interactive)
> =    (if (equal last-search-forward t)
> =       (search-forward  last-search-string)
> =       (search-backward last-search-string)))
> = 
> = (setq recording nil)
> = 
> = (defun cs-start-kbd-macro() (interactive)
> =    (if (equal recording t)
> =       (progn
> =          (setq recording nil)
> =          (end-kbd-macro))
> =       (progn
> =          (setq recording t)
> =          (start-kbd-macro nil))))
> = 
> = (defun cs-yank() (interactive)
> =    (save-excursion
> =       (forward-line 1)
> =       (yank)))
> = 
> = 
> = 
> = On Fri, Nov 29, 2002 at 08:40:18PM -0500, ken wrote:
> = > 
> = > Chris,
> = > 
> = > To get this when emacs loads, put the following in your .emacs:
> = > 
> = > (setq text-mode-hook 'turn-on-auto-fill)
> = > 
> = > As can be seen, that just sets it for text mode.  Do another for, say, 
> = > html-helper-mode:
> = > 
> = > (setq html-helper-mode-hook 'turn-on-auto-fill)
> = > 
> = > Personally, I turnaround at 78:
> = > 
> = > (setq-default fill-column 78)
> = > 
> = > Since versions seem to be more than normally critical, mine's 20.7.1.
> = > 
> = > 
> = > hth,
> = > ken
> = > 
> = > -- 
> = > AMD crashes?  See http://cleveland.lug.net/~ken/amd-problem/.
> = > 
> = > seberino@spawar.navy.mil at 15:22 (UTC-0800) on Thu, 28 Nov 2002 said:
> = > 
> = > = I often write comments and code and look at modeline's Column# display
> = > = to verify I did not go beyond the 80th column when I type.
> = > = 
> = > = Are there any goodies in Emacs to help me accomplish this???
> = > = 
> = > = 
> = > = Maybe....
> = > = 
> = > = 1. Emacs flashes the screen when I reach column 80
> = > = 
> = > = 2. Emacs automatically adds a hard return and moves me to next line
> = > =    when I reach column 80.
> = > = 
> = > = 3. Emacs just doesn't let me type beyond column 80.
> = > = 
> = > = Chris
> = > = 
> = 
> = 

-- 
_______________________________________

Dr. Christian Seberino
SPAWAR Systems Center San Diego
Code 2363
49590 Lassing Road, Room A339
San Diego, CA 92152-6147
U.S.A.

Phone: (619) 553-7940
Fax:   (619) 553-1269
Email: seberino@spawar.navy.mil
_______________________________________




reply via email to

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