Home | History | Annotate | Download | only in etc
      1 ;;; ============ NOTE WELL! =============
      2 ;;;
      3 ;;; You only need to use this file if you're using a version of Emacs
      4 ;;; prior to 20.1 to work on GDB.  The only difference between this
      5 ;;; and the standard add-log.el provided with 19.34 is that it
      6 ;;; generates dates using the terser format used by Emacs 20.  This is
      7 ;;; the format recommended for use in GDB ChangeLogs.
      8 ;;;
      9 ;;; To use this code, you should create a directory `~/elisp', save the code
     10 ;;; below in `~/elisp/add-log.el', and then put something like this in
     11 ;;; your `~/.emacs' file, to tell Emacs where to find it:
     12 ;;;
     13 ;;; (setq load-path
     14 ;;;       (cons (expand-file-name "~/elisp")
     15 ;;;             load-path))
     16 ;;;
     17 ;;; If you want, you can also byte-compile it --- it'll run a little
     18 ;;; faster, and use a little less memory.  (Not that those matter much for
     19 ;;; this file.)  To do that, after you've saved the text as
     20 ;;; ~/elisp/add-log.el, bring it up in Emacs, and type
     21 ;;;
     22 ;;;     C-u M-x byte-compile-file
     23 ;;;
     24 ;;; --- Jim Blandy
     25 
     26 ;;; add-log.el --- change log maintenance commands for Emacs
     27 
     28 ;; Copyright (C) 1985, 1986, 1988, 1993, 1994 Free Software Foundation, Inc.
     29 
     30 ;; Keywords: maint
     31 
     32 ;; This file is part of GNU Emacs.
     33 
     34 ;; GNU Emacs is free software; you can redistribute it and/or modify
     35 ;; it under the terms of the GNU General Public License as published by
     36 ;; the Free Software Foundation; either version 2, or (at your option)
     37 ;; any later version.
     38 
     39 ;; GNU Emacs is distributed in the hope that it will be useful,
     40 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
     41 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     42 ;; GNU General Public License for more details.
     43 
     44 ;; You should have received a copy of the GNU General Public License
     45 ;; along with GNU Emacs; see the file COPYING.  If not, write to the
     46 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
     47 ;; Boston, MA 02111-1307, USA.
     48 
     49 ;;; Commentary:
     50 
     51 ;; This facility is documented in the Emacs Manual.
     52 
     53 ;;; Code:
     54 
     55 (defvar change-log-default-name nil
     56   "*Name of a change log file for \\[add-change-log-entry].")
     57 
     58 (defvar add-log-current-defun-function nil
     59   "\
     60 *If non-nil, function to guess name of current function from surrounding text.
     61 \\[add-change-log-entry] calls this function (if nil, `add-log-current-defun'
     62 instead) with no arguments.  It returns a string or nil if it cannot guess.")
     63 
     64 ;;;###autoload
     65 (defvar add-log-full-name nil
     66   "*Full name of user, for inclusion in ChangeLog daily headers.
     67 This defaults to the value returned by the `user-full-name' function.")
     68 
     69 ;;;###autoload
     70 (defvar add-log-mailing-address nil
     71   "*Electronic mail address of user, for inclusion in ChangeLog daily headers.
     72 This defaults to the value of `user-mail-address'.")
     73 
     74 (defvar change-log-font-lock-keywords
     75   '(("^[SMTWF].+" . font-lock-function-name-face)	; Date line.
     76     ("^\t\\* \\([^ :\n]+\\)" 1 font-lock-comment-face)	; File name.
     77     ("(\\([^)\n]+\\)):" 1 font-lock-keyword-face))	; Function name.
     78   "Additional expressions to highlight in Change Log mode.")
     79 
     80 (defvar change-log-mode-map nil
     81   "Keymap for Change Log major mode.")
     82 (if change-log-mode-map
     83     nil
     84   (setq change-log-mode-map (make-sparse-keymap))
     85   (define-key change-log-mode-map "\M-q" 'change-log-fill-paragraph))
     86 
     87 (defun change-log-name ()
     88   (or change-log-default-name
     89       (if (eq system-type 'vax-vms)
     90 	  "$CHANGE_LOG$.TXT"
     91 	(if (or (eq system-type 'ms-dos) (eq system-type 'windows-nt))
     92 	    "changelo"
     93 	  "ChangeLog"))))
     94 
     95 ;;;###autoload
     96 (defun prompt-for-change-log-name ()
     97   "Prompt for a change log name."
     98   (let* ((default (change-log-name))
     99 	 (name (expand-file-name
    100 		(read-file-name (format "Log file (default %s): " default)
    101 				nil default))))
    102     ;; Handle something that is syntactically a directory name.
    103     ;; Look for ChangeLog or whatever in that directory.
    104     (if (string= (file-name-nondirectory name) "")
    105 	(expand-file-name (file-name-nondirectory default)
    106 			  name)
    107       ;; Handle specifying a file that is a directory.
    108       (if (file-directory-p name)
    109 	  (expand-file-name (file-name-nondirectory default)
    110 			    (file-name-as-directory name))
    111 	name))))
    112 
    113 ;;;###autoload
    114 (defun find-change-log (&optional file-name)
    115   "Find a change log file for \\[add-change-log-entry] and return the name.
    116 
    117 Optional arg FILE-NAME specifies the file to use.
    118 If FILE-NAME is nil, use the value of `change-log-default-name'.
    119 If 'change-log-default-name' is nil, behave as though it were 'ChangeLog'
    120 \(or whatever we use on this operating system).
    121 
    122 If 'change-log-default-name' contains a leading directory component, then
    123 simply find it in the current directory.  Otherwise, search in the current
    124 directory and its successive parents for a file so named.
    125 
    126 Once a file is found, `change-log-default-name' is set locally in the
    127 current buffer to the complete file name."
    128   ;; If user specified a file name or if this buffer knows which one to use,
    129   ;; just use that.
    130   (or file-name
    131       (setq file-name (and change-log-default-name
    132 			   (file-name-directory change-log-default-name)
    133 			   change-log-default-name))
    134       (progn
    135 	;; Chase links in the source file
    136 	;; and use the change log in the dir where it points.
    137 	(setq file-name (or (and buffer-file-name
    138 				 (file-name-directory
    139 				  (file-chase-links buffer-file-name)))
    140 			    default-directory))
    141 	(if (file-directory-p file-name)
    142 	    (setq file-name (expand-file-name (change-log-name) file-name)))
    143 	;; Chase links before visiting the file.
    144 	;; This makes it easier to use a single change log file
    145 	;; for several related directories.
    146 	(setq file-name (file-chase-links file-name))
    147 	(setq file-name (expand-file-name file-name))
    148 	;; Move up in the dir hierarchy till we find a change log file.
    149 	(let ((file1 file-name)
    150 	      parent-dir)
    151 	  (while (and (not (or (get-file-buffer file1) (file-exists-p file1)))
    152 		      (progn (setq parent-dir
    153 				   (file-name-directory
    154 				    (directory-file-name
    155 				     (file-name-directory file1))))
    156 			     ;; Give up if we are already at the root dir.
    157 			     (not (string= (file-name-directory file1)
    158 					   parent-dir))))
    159 	    ;; Move up to the parent dir and try again.
    160 	    (setq file1 (expand-file-name
    161 			 (file-name-nondirectory (change-log-name))
    162 			 parent-dir)))
    163 	  ;; If we found a change log in a parent, use that.
    164 	  (if (or (get-file-buffer file1) (file-exists-p file1))
    165 	      (setq file-name file1)))))
    166   ;; Make a local variable in this buffer so we needn't search again.
    167   (set (make-local-variable 'change-log-default-name) file-name)
    168   file-name)
    169 
    170 ;;;###autoload
    171 (defun add-change-log-entry (&optional whoami file-name other-window new-entry)
    172   "Find change log file and add an entry for today.
    173 Optional arg (interactive prefix) non-nil means prompt for user name and site.
    174 Second arg is file name of change log.  If nil, uses `change-log-default-name'.
    175 Third arg OTHER-WINDOW non-nil means visit in other window.
    176 Fourth arg NEW-ENTRY non-nil means always create a new entry at the front;
    177 never append to an existing entry."
    178   (interactive (list current-prefix-arg
    179 		     (prompt-for-change-log-name)))
    180   (or add-log-full-name
    181       (setq add-log-full-name (user-full-name)))
    182   (or add-log-mailing-address
    183       (setq add-log-mailing-address user-mail-address))
    184   (if whoami
    185       (progn
    186 	(setq add-log-full-name (read-input "Full name: " add-log-full-name))
    187 	 ;; Note that some sites have room and phone number fields in
    188 	 ;; full name which look silly when inserted.  Rather than do
    189 	 ;; anything about that here, let user give prefix argument so that
    190 	 ;; s/he can edit the full name field in prompter if s/he wants.
    191 	(setq add-log-mailing-address
    192 	      (read-input "Mailing address: " add-log-mailing-address))))
    193   (let ((defun (funcall (or add-log-current-defun-function
    194 			    'add-log-current-defun)))
    195 	paragraph-end entry)
    196 
    197     (setq file-name (expand-file-name (find-change-log file-name)))
    198 
    199     ;; Set ENTRY to the file name to use in the new entry.
    200     (and buffer-file-name
    201 	 ;; Never want to add a change log entry for the ChangeLog file itself.
    202 	 (not (string= buffer-file-name file-name))
    203 	 (setq entry (if (string-match
    204 			  (concat "^" (regexp-quote (file-name-directory
    205 						     file-name)))
    206 			  buffer-file-name)
    207 			 (substring buffer-file-name (match-end 0))
    208 		       (file-name-nondirectory buffer-file-name))))
    209 
    210     (if (and other-window (not (equal file-name buffer-file-name)))
    211 	(find-file-other-window file-name)
    212       (find-file file-name))
    213     (or (eq major-mode 'change-log-mode)
    214 	(change-log-mode))
    215     (undo-boundary)
    216     (goto-char (point-min))
    217     (let ((heading (format "%s  %s  <%s>"
    218 			   (format-time-string "%Y-%m-%d")
    219 			   add-log-full-name
    220 			   add-log-mailing-address)))
    221       (if (looking-at (regexp-quote heading))
    222 	  (forward-line 1)
    223 	(insert heading "\n\n")))
    224 
    225     ;; Search only within the first paragraph.
    226     (if (looking-at "\n*[^\n* \t]")
    227 	(skip-chars-forward "\n")
    228       (forward-paragraph 1))
    229     (setq paragraph-end (point))
    230     (goto-char (point-min))
    231 
    232     ;; Now insert the new line for this entry.
    233     (cond ((re-search-forward "^\\s *\\*\\s *$" paragraph-end t)
    234 	   ;; Put this file name into the existing empty entry.
    235 	   (if entry
    236 	       (insert entry)))
    237 	  ((and (not new-entry)
    238 		(let (case-fold-search)
    239 		  (re-search-forward
    240 		   (concat (regexp-quote (concat "* " entry))
    241 			   ;; Don't accept `foo.bar' when
    242 			   ;; looking for `foo':
    243 			   "\\(\\s \\|[(),:]\\)")
    244 		   paragraph-end t)))
    245 	   ;; Add to the existing entry for the same file.
    246 	   (re-search-forward "^\\s *$\\|^\\s \\*")
    247 	   (goto-char (match-beginning 0))
    248 	   ;; Delete excess empty lines; make just 2.
    249 	   (while (and (not (eobp)) (looking-at "^\\s *$"))
    250 	     (delete-region (point) (save-excursion (forward-line 1) (point))))
    251 	   (insert "\n\n")
    252 	   (forward-line -2)
    253 	   (indent-relative-maybe))
    254 	  (t
    255 	   ;; Make a new entry.
    256 	   (forward-line 1)
    257 	   (while (looking-at "\\sW")
    258 	     (forward-line 1))
    259 	   (while (and (not (eobp)) (looking-at "^\\s *$"))
    260 	     (delete-region (point) (save-excursion (forward-line 1) (point))))
    261 	   (insert "\n\n\n")
    262 	   (forward-line -2)
    263 	   (indent-to left-margin)
    264 	   (insert "* " (or entry ""))))
    265     ;; Now insert the function name, if we have one.
    266     ;; Point is at the entry for this file,
    267     ;; either at the end of the line or at the first blank line.
    268     (if defun
    269 	(progn
    270 	  ;; Make it easy to get rid of the function name.
    271 	  (undo-boundary)
    272 	  (insert (if (save-excursion
    273 			(beginning-of-line 1)
    274 			(looking-at "\\s *$"))
    275 		      ""
    276 		    " ")
    277 		  "(" defun "): "))
    278       ;; No function name, so put in a colon unless we have just a star.
    279       (if (not (save-excursion
    280 		 (beginning-of-line 1)
    281 		 (looking-at "\\s *\\(\\*\\s *\\)?$")))
    282 	  (insert ": ")))))
    283 
    284 ;;;###autoload
    285 (defun add-change-log-entry-other-window (&optional whoami file-name)
    286   "Find change log file in other window and add an entry for today.
    287 Optional arg (interactive prefix) non-nil means prompt for user name and site.
    288 Second arg is file name of change log.  \
    289 If nil, uses `change-log-default-name'."
    290   (interactive (if current-prefix-arg
    291 		   (list current-prefix-arg
    292 			 (prompt-for-change-log-name))))
    293   (add-change-log-entry whoami file-name t))
    294 ;;;###autoload (define-key ctl-x-4-map "a" 'add-change-log-entry-other-window)
    295 
    296 ;;;###autoload
    297 (defun change-log-mode ()
    298   "Major mode for editing change logs; like Indented Text Mode.
    299 Prevents numeric backups and sets `left-margin' to 8 and `fill-column' to 74.
    300 New log entries are usually made with \\[add-change-log-entry] or \\[add-change-log-entry-other-window].
    301 Each entry behaves as a paragraph, and the entries for one day as a page.
    302 Runs `change-log-mode-hook'."
    303   (interactive)
    304   (kill-all-local-variables)
    305   (indented-text-mode)
    306   (setq major-mode 'change-log-mode
    307 	mode-name "Change Log"
    308 	left-margin 8
    309 	fill-column 74
    310     indent-tabs-mode t
    311     tab-width 8)
    312   (use-local-map change-log-mode-map)
    313   ;; Let each entry behave as one paragraph:
    314   ;; We really do want "^" in paragraph-start below: it is only the lines that
    315   ;; begin at column 0 (despite the left-margin of 8) that we are looking for.
    316   (set (make-local-variable 'paragraph-start) "\\s *$\\|\f\\|^\\sw")
    317   (set (make-local-variable 'paragraph-separate) "\\s *$\\|\f\\|^\\sw")
    318   ;; Let all entries for one day behave as one page.
    319   ;; Match null string on the date-line so that the date-line
    320   ;; is grouped with what follows.
    321   (set (make-local-variable 'page-delimiter) "^\\<\\|^\f")
    322   (set (make-local-variable 'version-control) 'never)
    323   (set (make-local-variable 'adaptive-fill-regexp) "\\s *")
    324   (set (make-local-variable 'font-lock-defaults)
    325        '(change-log-font-lock-keywords t))
    326   (run-hooks 'change-log-mode-hook))
    327 
    328 ;; It might be nice to have a general feature to replace this.  The idea I
    329 ;; have is a variable giving a regexp matching text which should not be
    330 ;; moved from bol by filling.  change-log-mode would set this to "^\\s *\\s(".
    331 ;; But I don't feel up to implementing that today.
    332 (defun change-log-fill-paragraph (&optional justify)
    333   "Fill the paragraph, but preserve open parentheses at beginning of lines.
    334 Prefix arg means justify as well."
    335   (interactive "P")
    336   (let ((end (save-excursion (forward-paragraph) (point)))
    337 	(beg (save-excursion (backward-paragraph)(point)))
    338 	(paragraph-start (concat paragraph-start "\\|\\s *\\s(")))
    339     (fill-region beg end justify)))
    340 
    341 (defvar add-log-current-defun-header-regexp
    343   "^\\([A-Z][A-Z_ ]*[A-Z_]\\|[-_a-zA-Z]+\\)[ \t]*[:=]"
    344   "*Heuristic regexp used by `add-log-current-defun' for unknown major modes.")
    345 
    346 ;;;###autoload
    347 (defun add-log-current-defun ()
    348   "Return name of function definition point is in, or nil.
    349 
    350 Understands C, Lisp, LaTeX (\"functions\" are chapters, sections, ...),
    351 Texinfo (@node titles), Perl, and Fortran.
    352 
    353 Other modes are handled by a heuristic that looks in the 10K before
    354 point for uppercase headings starting in the first column or
    355 identifiers followed by `:' or `=', see variable
    356 `add-log-current-defun-header-regexp'.
    357 
    358 Has a preference of looking backwards."
    359   (condition-case nil
    360       (save-excursion
    361 	(let ((location (point)))
    362 	  (cond ((memq major-mode '(emacs-lisp-mode lisp-mode scheme-mode
    363 						    lisp-interaction-mode))
    364 		 ;; If we are now precisely at the beginning of a defun,
    365 		 ;; make sure beginning-of-defun finds that one
    366 		 ;; rather than the previous one.
    367 		 (or (eobp) (forward-char 1))
    368 		 (beginning-of-defun)
    369 		 ;; Make sure we are really inside the defun found, not after it.
    370 		 (if (and (looking-at "\\s(")
    371 			  (progn (end-of-defun)
    372 				 (< location (point)))
    373 			  (progn (forward-sexp -1)
    374 				 (>= location (point))))
    375 		     (progn
    376 		       (if (looking-at "\\s(")
    377 			   (forward-char 1))
    378 		       (forward-sexp 1)
    379 		       (skip-chars-forward " '")
    380 		       (buffer-substring (point)
    381 					 (progn (forward-sexp 1) (point))))))
    382 		((and (memq major-mode '(c-mode c++-mode c++-c-mode objc-mode))
    383 		      (save-excursion (beginning-of-line)
    384 				      ;; Use eq instead of = here to avoid
    385 				      ;; error when at bob and char-after
    386 				      ;; returns nil.
    387 				      (while (eq (char-after (- (point) 2)) ?\\)
    388 					(forward-line -1))
    389 				      (looking-at "[ \t]*#[ \t]*define[ \t]")))
    390 		 ;; Handle a C macro definition.
    391 		 (beginning-of-line)
    392 		 (while (eq (char-after (- (point) 2)) ?\\) ;not =; note above
    393 		   (forward-line -1))
    394 		 (search-forward "define")
    395 		 (skip-chars-forward " \t")
    396 		 (buffer-substring (point)
    397 				   (progn (forward-sexp 1) (point))))
    398 		((memq major-mode '(c-mode c++-mode c++-c-mode objc-mode))
    399 		 (beginning-of-line)
    400 		 ;; See if we are in the beginning part of a function,
    401 		 ;; before the open brace.  If so, advance forward.
    402 		 (while (not (looking-at "{\\|\\(\\s *$\\)"))
    403 		   (forward-line 1))
    404 		 (or (eobp)
    405 		     (forward-char 1))
    406 		 (beginning-of-defun)
    407 		 (if (progn (end-of-defun)
    408 			    (< location (point)))
    409 		     (progn
    410 		       (backward-sexp 1)
    411 		       (let (beg tem)
    412 
    413 			 (forward-line -1)
    414 			 ;; Skip back over typedefs of arglist.
    415 			 (while (and (not (bobp))
    416 				     (looking-at "[ \t\n]"))
    417 			   (forward-line -1))
    418 			 ;; See if this is using the DEFUN macro used in Emacs,
    419 			 ;; or the DEFUN macro used by the C library.
    420 			 (if (condition-case nil
    421 				 (and (save-excursion
    422 					(end-of-line)
    423 					(while (= (preceding-char) ?\\)
    424 					  (end-of-line 2))
    425 					(backward-sexp 1)
    426 					(beginning-of-line)
    427 					(setq tem (point))
    428 					(looking-at "DEFUN\\b"))
    429 				      (>= location tem))
    430 			       (error nil))
    431 			     (progn
    432 			       (goto-char tem)
    433 			       (down-list 1)
    434 			       (if (= (char-after (point)) ?\")
    435 				   (progn
    436 				     (forward-sexp 1)
    437 				     (skip-chars-forward " ,")))
    438 			       (buffer-substring (point)
    439 						 (progn (forward-sexp 1) (point))))
    440                            (if (looking-at "^[+-]")
    441                                (get-method-definition)
    442                              ;; Ordinary C function syntax.
    443                              (setq beg (point))
    444                              (if (and (condition-case nil
    445 					  ;; Protect against "Unbalanced parens" error.
    446 					  (progn
    447 					    (down-list 1) ; into arglist
    448 					    (backward-up-list 1)
    449 					    (skip-chars-backward " \t")
    450 					    t)
    451 					(error nil))
    452 				      ;; Verify initial pos was after
    453 				      ;; real start of function.
    454 				      (save-excursion
    455 					(goto-char beg)
    456 					;; For this purpose, include the line
    457 					;; that has the decl keywords.  This
    458 					;; may also include some of the
    459 					;; comments before the function.
    460 					(while (and (not (bobp))
    461 						    (save-excursion
    462 						      (forward-line -1)
    463 						      (looking-at "[^\n\f]")))
    464 					  (forward-line -1))
    465 					(>= location (point)))
    466                                           ;; Consistency check: going down and up
    467                                           ;; shouldn't take us back before BEG.
    468                                           (> (point) beg))
    469 				 (let (end middle)
    470 				   ;; Don't include any final newline
    471 				   ;; in the name we use.
    472 				   (if (= (preceding-char) ?\n)
    473 				       (forward-char -1))
    474 				   (setq end (point))
    475 				   (backward-sexp 1)
    476 				   ;; Now find the right beginning of the name.
    477 				   ;; Include certain keywords if they
    478 				   ;; precede the name.
    479 				   (setq middle (point))
    480 				   (forward-word -1)
    481 				   ;; Ignore these subparts of a class decl
    482 				   ;; and move back to the class name itself.
    483 				   (while (looking-at "public \\|private ")
    484 				     (skip-chars-backward " \t:")
    485 				     (setq end (point))
    486 				     (backward-sexp 1)
    487 				     (setq middle (point))
    488 				     (forward-word -1))
    489 				   (and (bolp)
    490 					(looking-at "struct \\|union \\|class ")
    491 					(setq middle (point)))
    492 				   (buffer-substring middle end)))))))))
    493 		((memq major-mode
    494 		       '(TeX-mode plain-TeX-mode LaTeX-mode;; tex-mode.el
    495 				  plain-tex-mode latex-mode;; cmutex.el
    496 				  ))
    497 		 (if (re-search-backward
    498 		      "\\\\\\(sub\\)*\\(section\\|paragraph\\|chapter\\)" nil t)
    499 		     (progn
    500 		       (goto-char (match-beginning 0))
    501 		       (buffer-substring (1+ (point));; without initial backslash
    502 					 (progn
    503 					   (end-of-line)
    504 					   (point))))))
    505 		((eq major-mode 'texinfo-mode)
    506 		 (if (re-search-backward "^@node[ \t]+\\([^,\n]+\\)" nil t)
    507 		     (buffer-substring (match-beginning 1)
    508 				       (match-end 1))))
    509 		((eq major-mode 'perl-mode)
    510 		 (if (re-search-backward "^sub[ \t]+\\([^ \t\n]+\\)" nil t)
    511 		     (buffer-substring (match-beginning 1)
    512 				       (match-end 1))))
    513                 ((eq major-mode 'fortran-mode)
    514                  ;; must be inside function body for this to work
    515                  (beginning-of-fortran-subprogram)
    516                  (let ((case-fold-search t)) ; case-insensitive
    517                    ;; search for fortran subprogram start
    518                    (if (re-search-forward
    519 			 "^[ \t]*\\(program\\|subroutine\\|function\
    520 \\|[ \ta-z0-9*]*[ \t]+function\\)"
    521 			 nil t)
    522                        (progn
    523                          ;; move to EOL or before first left paren
    524                          (if (re-search-forward "[(\n]" nil t)
    525 			     (progn (forward-char -1)
    526 				    (skip-chars-backward " \t"))
    527 			   (end-of-line))
    528 			 ;; Use the name preceding that.
    529                          (buffer-substring (point)
    530                                            (progn (forward-sexp -1)
    531                                                   (point)))))))
    532 		(t
    533 		 ;; If all else fails, try heuristics
    534 		 (let (case-fold-search)
    535 		   (end-of-line)
    536 		   (if (re-search-backward add-log-current-defun-header-regexp
    537 					   (- (point) 10000)
    538 					   t)
    539 		       (buffer-substring (match-beginning 1)
    540 					 (match-end 1))))))))
    541     (error nil)))
    542 
    543 (defvar get-method-definition-md)
    544 
    545 ;; Subroutine used within get-method-definition.
    546 ;; Add the last match in the buffer to the end of `md',
    547 ;; followed by the string END; move to the end of that match.
    548 (defun get-method-definition-1 (end)
    549   (setq get-method-definition-md
    550 	(concat get-method-definition-md
    551 		(buffer-substring (match-beginning 1) (match-end 1))
    552 		end))
    553   (goto-char (match-end 0)))
    554 
    555 ;; For objective C, return the method name if we are in a method.
    556 (defun get-method-definition ()
    557   (let ((get-method-definition-md "["))
    558     (save-excursion
    559       (if (re-search-backward "^@implementation\\s-*\\([A-Za-z_]*\\)" nil t)
    560 	  (get-method-definition-1 " ")))
    561     (save-excursion
    562       (cond
    563        ((re-search-forward "^\\([-+]\\)[ \t\n\f\r]*\\(([^)]*)\\)?\\s-*" nil t)
    564 	(get-method-definition-1 "")
    565 	(while (not (looking-at "[{;]"))
    566 	  (looking-at
    567 	   "\\([A-Za-z_]*:?\\)\\s-*\\(([^)]*)\\)?[A-Za-z_]*[ \t\n\f\r]*")
    568 	  (get-method-definition-1 ""))
    569 	(concat get-method-definition-md "]"))))))
    570 
    571 
    572 (provide 'add-log)
    573 
    574 ;;; add-log.el ends here
    575