comparison lisp/add-log.el @ 951:c23539669808

*** empty log message ***
author Roland McGrath <roland@gnu.org>
date Fri, 07 Aug 1992 21:31:57 +0000
parents c45ba80a9da9
children 7c035a87c691
comparison
equal deleted inserted replaced
950:79204001d346 951:c23539669808
84 (if (and other-window (not (equal file-name buffer-file-name))) 84 (if (and other-window (not (equal file-name buffer-file-name)))
85 (find-file-other-window file-name) 85 (find-file-other-window file-name)
86 (find-file file-name)) 86 (find-file file-name))
87 (undo-boundary) 87 (undo-boundary)
88 (goto-char (point-min)) 88 (goto-char (point-min))
89 (if (not (and (looking-at (substring (current-time-string) 0 10)) 89 (or (looking-at (concat (substring (current-time-string) 0 10)
90 (looking-at (concat ".* " full-name " (" login-name "@")))) 90 ".* " full-name " (" login-name "@"))
91 (progn (insert (current-time-string) 91 (insert (current-time-string)
92 " " full-name 92 " " full-name
93 " (" login-name 93 " (" login-name
94 "@" site-name ")\n\n"))) 94 "@" site-name ")\n\n"))
95 (goto-char (point-min)) 95 (goto-char (point-min))
96 (setq empty-entry 96 (setq empty-entry
97 (and (search-forward "\n\t* \n" nil t) 97 (and (search-forward "\n\t* \n" nil t)
98 (1- (point)))) 98 (1- (point))))
99 (if (and entry 99 (if (and entry
178 (add-change-log-entry whoami file-name t)) 178 (add-change-log-entry whoami file-name t))
179 179
180 (defun change-log-mode () 180 (defun change-log-mode ()
181 "Major mode for editting change logs; like Indented Text Mode. 181 "Major mode for editting change logs; like Indented Text Mode.
182 Prevents numeric backups and sets `left-margin' to 8 and `fill-column' to 74. 182 Prevents numeric backups and sets `left-margin' to 8 and `fill-column' to 74.
183 New log entries are usually made with \\[add-change-log-entry] or \\[add-change-log-entry-other-window]." 183 New log entries are usually made with \\[add-change-log-entry] or \\[add-change-log-entry-other-window].
184 Each entry behaves as a paragraph, and the entries for one day as a page.
185 Runs `change-log-mode-hook'."
184 (interactive) 186 (interactive)
185 (kill-all-local-variables) 187 (kill-all-local-variables)
186 (indented-text-mode) 188 (indented-text-mode)
187 (setq major-mode 'change-log-mode) 189 (setq major-mode 'change-log-mode)
188 (setq mode-name "Change Log") 190 (setq mode-name "Change Log")
234 (progn 236 (progn
235 (forward-word 1) 237 (forward-word 1)
236 (skip-chars-forward " ") 238 (skip-chars-forward " ")
237 (buffer-substring (point) 239 (buffer-substring (point)
238 (progn (forward-sexp 1) (point)))))) 240 (progn (forward-sexp 1) (point))))))
239 ((and (or (eq major-mode 'c-mode) 241 ((and (memq major-mode '(c-mode 'c++-mode))
240 (eq major-mode 'c++-mode))
241 (save-excursion (beginning-of-line) 242 (save-excursion (beginning-of-line)
242 ;; Use eq instead of = here to avoid 243 ;; Use eq instead of = here to avoid
243 ;; error when at bob and char-after 244 ;; error when at bob and char-after
244 ;; returns nil. 245 ;; returns nil.
245 (while (eq (char-after (- (point) 2)) ?\\) 246 (while (eq (char-after (- (point) 2)) ?\\)
251 (forward-line -1)) 252 (forward-line -1))
252 (search-forward "define") 253 (search-forward "define")
253 (skip-chars-forward " \t") 254 (skip-chars-forward " \t")
254 (buffer-substring (point) 255 (buffer-substring (point)
255 (progn (forward-sexp 1) (point)))) 256 (progn (forward-sexp 1) (point))))
256 ((or (eq major-mode 'c-mode) 257 ((memq major-mode '(c-mode 'c++-mode))
257 (eq major-mode 'c++-mode))
258 ;; See if we are in the beginning part of a function, 258 ;; See if we are in the beginning part of a function,
259 ;; before the open brace. If so, advance forward. 259 ;; before the open brace. If so, advance forward.
260 (while (not (or (looking-at "{") 260 (while (not (looking-at "{\\|\\(\\s *$\\)"))
261 (looking-at "\\s *$")))
262 (forward-line 1)) 261 (forward-line 1))
263 (or (eobp) (forward-char 1)) 262 (or (eobp)
263 (forward-char 1))
264 (beginning-of-defun) 264 (beginning-of-defun)
265 (if (progn (end-of-defun) 265 (if (progn (end-of-defun)
266 (< location (point))) 266 (< location (point)))
267 (progn 267 (progn
268 (backward-sexp 1) 268 (backward-sexp 1)
271 (forward-line -1) 271 (forward-line -1)
272 ;; Skip back over typedefs of arglist. 272 ;; Skip back over typedefs of arglist.
273 (while (and (not (bobp)) 273 (while (and (not (bobp))
274 (looking-at "[ \t\n]")) 274 (looking-at "[ \t\n]"))
275 (forward-line -1)) 275 (forward-line -1))
276 ;; See if this is using the DEFUN macro used in Emacs. 276 ;; See if this is using the DEFUN macro used in Emacs,
277 (if (save-excursion 277 ;; or the DEFUN macro used by the C library.
278 (while (and (not (bobp)) 278 (if (and (looking-at "DEFUN\\b")
279 (looking-at "[^\n\f]") 279 (>= location (point)))
280 (not (looking-at ".*\\*/")))
281 (forward-line -1))
282 (forward-line 1)
283 (setq tem (point))
284 (and (looking-at "DEFUN ")
285 (>= location (point))))
286 (progn 280 (progn
287 (goto-char tem)
288 (down-list 1) 281 (down-list 1)
289 (forward-sexp 1) 282 (if (= (char-after (point)) ?\")
290 (skip-chars-forward " ,") 283 (progn
284 (forward-sexp 1)
285 (skip-chars-forward " ,")))
291 (buffer-substring (point) 286 (buffer-substring (point)
292 (progn (forward-sexp 1) (point)))) 287 (progn (forward-sexp 1) (point))))
293 ;; Ordinary C function syntax. 288 ;; Ordinary C function syntax.
294 (setq beg (point)) 289 (setq beg (point))
295 (down-list 1) ; into arglist 290 (down-list 1) ; into arglist
301 ;; For this purpose, include the line 296 ;; For this purpose, include the line
302 ;; that has the decl keywords. 297 ;; that has the decl keywords.
303 ;; This may also include some of the comments 298 ;; This may also include some of the comments
304 ;; before the function. 299 ;; before the function.
305 (while (and (not (bobp)) 300 (while (and (not (bobp))
306 (save-excursion (forward-line -1) 301 (save-excursion
307 (looking-at "[^\n\f]"))) 302 (forward-line -1)
303 (looking-at "[^\n\f]")))
308 (forward-line -1)) 304 (forward-line -1))
309 (>= location (point))) 305 (>= location (point)))
310 ;; Consistency check: going down and up 306 ;; Consistency check: going down and up
311 ;; shouldn't take us back before BEG. 307 ;; shouldn't take us back before BEG.
312 (> (point) beg)) 308 (> (point) beg))