[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Automatic Mode Lines
Date: Wed, 2 Dec 87 13:53 EST
From: J. Scott Penberthy <JSP@IBM.COM>
Date: Wed, 2 Dec 87 10:22 EST
From: Scott McKay <SWM@SAPSUCKER.SCRC.Symbolics.COM>
Date: Tue, 1 Dec 87 10:47 EST
From: J. Scott Penberthy <JSP@IBM.COM>
Does anyone have a hack that automatically inserts a mode line in a newly
created LISP mode buffer? If not, is there an undocumented feature of
ZMACS that does the same?
Thanks,
Scott
m-X Update Attribute List?
No -- I'm more interested in an 1automatic0 method for writing the
attribute list whenever a new, LISP-mode buffer is created. The "Update
Attribute List" command just uses the current defaults for the mode
line. However, I want to use a different mode line (or set of lines),
something like
;;; -*- Mode: LISP; Syntax: Common-Lisp; Package: USER; Base 10; VSP: 0 -*-
;;;
;;; This file was created on <date> by <pretty user name> on <machine>
;;; <License info>
I don't think that the Update Attribute List command will automatically
insert the VSP option; it certainly won't generate a multi-line header.
I'd also like this header to be generated automatically whenever I
create a new buffer; the less keystrokes, the better.
Is there something like a "newly-generated-file-buffer-hook"? Such a hook
could solve this problem.
Cheers,
Scott
I am almost embarrassed to send this to anyone, but it works for me. I think
that it is self explanatory. I also including 2com-insert-modified-by-string
0which you might find useful, I do. I use the key bindings of hyper-i for initial
and hyper-c for change.
-m.
2(defcom com-create-initial-attribute-list 0"create an initial attribute list"2 ()
0 2(let ((start-bp (copy-bp (interval-first-bp *interval*)))
0 2(mode-keyword (send *major-mode* :major-mode-keyword)))
0 2(insert-moving start-bp
0 2(format nil
0 ";;; -*- Mode: ~A; Package: ~A;~@[ Syntax: ~A;~] Base: 10; Vsp: 0 -*-~
~&;;; Created ~\\Date\\ by ~A on ~A at ~A~2%"
2mode-keyword
0 2(pkg-name cl:*package*)
0 2(when (eq mode-keyword :lisp)
0 ;; syntax only applies to lisp buffers
2(let ((buffer-syntax (send *interval* :get :syntax)))
0 ;; if the buffer has a syntax already, use it.
;; Otherwise use CL
2(if buffer-syntax
0 2(cl:string-capitalize (format nil 0"~A"2 buffer-syntax))
0 "Common-Lisp"2)))
0 2(cl:get-universal-time)
0 2user-id
0 2(cl:machine-instance)
0 2(cl:short-site-name)))
0 ;; because of my homebrew electric-style-lock mode.
2(com-reparse-attribute-list)
0 2(when (eq mode-keyword :lisp)
0 ;; change font of comment we just wrote if this is lisp mode
2(change-style-interval (copy-bp (interval-first-bp *interval*)) start-bp
0 2t0 2(si:style-index (si:parse-character-style '(nil nil nil))))))
0 ;; return a redisplay option
2dis-text)
(defcom com-insert-modified-by-string
0 "Insert a comment as second line of the buffer describing who, what, what time and why"2 ()
0 2(com-goto-beginning)
0 2(down-real-line 1)
0 2(let ((stream (open-interval-stream (point))))
0 2(format stream
0 "~a~a~a"2 0";;; modified by "
2(send si:*user* :personal-name-first-name-first)
0 " "2)
0 2(time:print-current-time stream)
0 2(format stream 0"~a"2 0" purpose: "2)
0 2(send stream :tyo #\cr))
0 2(com-end-of-line)
0 2dis-text)