diff options
| author | Stefan Monnier | 1999-12-02 16:27:21 +0000 |
|---|---|---|
| committer | Stefan Monnier | 1999-12-02 16:27:21 +0000 |
| commit | be961cd5aa189b00a9e206d546ced7e8809c0d8f (patch) | |
| tree | 2cc5141d3b31be4c2c98cbd31f94f95c5145a1ae | |
| parent | 867ef43ab163f14999a93f2eca0b767d27037b03 (diff) | |
| download | emacs-be961cd5aa189b00a9e206d546ced7e8809c0d8f.tar.gz emacs-be961cd5aa189b00a9e206d546ced7e8809c0d8f.zip | |
(lm-header-multiline): fix spurious use of `cond'.
(lm-with-file): Move all the find-file...kill-buffer stuff into
this macro. Make it use `find-file-noselect' and make it kill
the buffer only if it wasn't already displayed somewhere.
(lm-summary, lm-authors, lm-maintainer, lm-creation-date)
(lm-last-modified-date, lm-version, lm-keywords, lm-adapted-by)
(lm-commentary, lm-verify, lm-synopsis): use lm-with-file.
(lm-commentary): fix to handle the case when the change log is
at the end of the file.
| -rw-r--r-- | lisp/ChangeLog | 15 | ||||
| -rw-r--r-- | lisp/emacs-lisp/lisp-mnt.el | 296 |
2 files changed, 131 insertions, 180 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 93100dc18ec..1fc84e33fab 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -1,3 +1,16 @@ | |||
| 1 | 1999-12-02 Stefan Monnier <monnier@cs.yale.edu> | ||
| 2 | |||
| 3 | * emacs-lisp/lisp-mnt.el (lm-header-multiline): fix spurious | ||
| 4 | use of `cond'. | ||
| 5 | (lm-with-file): Move all the find-file...kill-buffer stuff into | ||
| 6 | this macro. Make it use `find-file-noselect' and make it kill | ||
| 7 | the buffer only if it wasn't already displayed somewhere. | ||
| 8 | (lm-summary, lm-authors, lm-maintainer, lm-creation-date) | ||
| 9 | (lm-last-modified-date, lm-version, lm-keywords, lm-adapted-by) | ||
| 10 | (lm-commentary, lm-verify, lm-synopsis): use lm-with-file. | ||
| 11 | (lm-commentary): fix to handle the case when the change log is | ||
| 12 | at the end of the file. | ||
| 13 | |||
| 1 | 1999-12-02 Kenichi Handa <handa@etl.go.jp> | 14 | 1999-12-02 Kenichi Handa <handa@etl.go.jp> |
| 2 | 15 | ||
| 3 | * international/mule.el (charsetp): Fix typo in docstring. | 16 | * international/mule.el (charsetp): Fix typo in docstring. |
| @@ -42,7 +55,7 @@ | |||
| 42 | 55 | ||
| 43 | 1999-11-30 Dave Love <fx@gnu.org> | 56 | 1999-11-30 Dave Love <fx@gnu.org> |
| 44 | 57 | ||
| 45 | * fortran.el (fortran-strip-sqeuence-nos): New command. | 58 | * fortran.el (fortran-strip-sequence-nos): New command. |
| 46 | 59 | ||
| 47 | * autoinsert.el: Minor doc fixes. | 60 | * autoinsert.el: Minor doc fixes. |
| 48 | (auto-insert): Return nil. | 61 | (auto-insert): Return nil. |
diff --git a/lisp/emacs-lisp/lisp-mnt.el b/lisp/emacs-lisp/lisp-mnt.el index 47e64294699..3e15384d028 100644 --- a/lisp/emacs-lisp/lisp-mnt.el +++ b/lisp/emacs-lisp/lisp-mnt.el | |||
| @@ -218,8 +218,7 @@ The returned value is a list of strings, one per line." | |||
| 218 | (save-excursion | 218 | (save-excursion |
| 219 | (goto-char (point-min)) | 219 | (goto-char (point-min)) |
| 220 | (let ((res (lm-header header))) | 220 | (let ((res (lm-header header))) |
| 221 | (cond | 221 | (when res |
| 222 | (res | ||
| 223 | (setq res (list res)) | 222 | (setq res (list res)) |
| 224 | (forward-line 1) | 223 | (forward-line 1) |
| 225 | 224 | ||
| @@ -233,32 +232,37 @@ The returned value is a list of strings, one per line." | |||
| 233 | (match-end 1)) | 232 | (match-end 1)) |
| 234 | res)) | 233 | res)) |
| 235 | (forward-line 1)) | 234 | (forward-line 1)) |
| 236 | )) | 235 | ) |
| 237 | res | 236 | res |
| 238 | ))) | 237 | ))) |
| 239 | 238 | ||
| 240 | ;; These give us smart access to the header fields and commentary | 239 | ;; These give us smart access to the header fields and commentary |
| 241 | 240 | ||
| 241 | (defmacro lm-with-file (file &rest body) | ||
| 242 | (let ((filesym (make-symbol "file"))) | ||
| 243 | `(save-excursion | ||
| 244 | (let ((,filesym ,file)) | ||
| 245 | (if ,filesym (set-buffer (find-file-noselect ,filesym))) | ||
| 246 | (prog1 (progn ,@body) | ||
| 247 | (if (and ,filesym (not (get-buffer-window (current-buffer) t))) | ||
| 248 | (kill-buffer (current-buffer)))))))) | ||
| 249 | (put 'lm-with-file 'lisp-indent-function 1) | ||
| 250 | (put 'lm-with-file 'edebug-form-spec t) | ||
| 251 | |||
| 242 | (defun lm-summary (&optional file) | 252 | (defun lm-summary (&optional file) |
| 243 | "Return the one-line summary of file FILE, or current buffer if FILE is nil." | 253 | "Return the one-line summary of file FILE, or current buffer if FILE is nil." |
| 244 | (save-excursion | 254 | (lm-with-file file |
| 245 | (if file | ||
| 246 | (find-file file)) | ||
| 247 | (goto-char (point-min)) | 255 | (goto-char (point-min)) |
| 248 | (prog1 | 256 | (if (and |
| 249 | (if (and | 257 | (looking-at lm-header-prefix) |
| 250 | (looking-at lm-header-prefix) | 258 | (progn (goto-char (match-end 0)) |
| 251 | (progn (goto-char (match-end 0)) | 259 | (looking-at "[^ ]+[ \t]+--+[ \t]+\\(.*\\)"))) |
| 252 | (looking-at "[^ ]+[ \t]+--+[ \t]+\\(.*\\)"))) | 260 | (let ((summary (buffer-substring-no-properties (match-beginning 1) |
| 253 | (let ((summary (buffer-substring-no-properties (match-beginning 1) | 261 | (match-end 1)))) |
| 254 | (match-end 1)))) | 262 | ;; Strip off -*- specifications. |
| 255 | ;; Strip off -*- specifications. | 263 | (if (string-match "[ \t]*-\\*-.*-\\*-" summary) |
| 256 | (if (string-match "[ \t]*-\\*-.*-\\*-" summary) | 264 | (substring summary 0 (match-beginning 0)) |
| 257 | (substring summary 0 (match-beginning 0)) | 265 | summary))))) |
| 258 | summary))) | ||
| 259 | (if file | ||
| 260 | (kill-buffer (current-buffer))) | ||
| 261 | ))) | ||
| 262 | 266 | ||
| 263 | (defun lm-crack-address (x) | 267 | (defun lm-crack-address (x) |
| 264 | "Split up an email address X into full name and real email address. | 268 | "Split up an email address X into full name and real email address. |
| @@ -278,144 +282,89 @@ The value is a cons of the form (FULLNAME . ADDRESS)." | |||
| 278 | "Return the author list of file FILE, or current buffer if FILE is nil. | 282 | "Return the author list of file FILE, or current buffer if FILE is nil. |
| 279 | Each element of the list is a cons; the car is the full name, | 283 | Each element of the list is a cons; the car is the full name, |
| 280 | the cdr is an email address." | 284 | the cdr is an email address." |
| 281 | (save-excursion | 285 | (lm-with-file file |
| 282 | (if file | ||
| 283 | (find-file file)) | ||
| 284 | (let ((authorlist (lm-header-multiline "author"))) | 286 | (let ((authorlist (lm-header-multiline "author"))) |
| 285 | (prog1 | 287 | (mapcar 'lm-crack-address authorlist)))) |
| 286 | (mapcar 'lm-crack-address authorlist) | ||
| 287 | (if file | ||
| 288 | (kill-buffer (current-buffer))) | ||
| 289 | )))) | ||
| 290 | 288 | ||
| 291 | (defun lm-maintainer (&optional file) | 289 | (defun lm-maintainer (&optional file) |
| 292 | "Return the maintainer of file FILE, or current buffer if FILE is nil. | 290 | "Return the maintainer of file FILE, or current buffer if FILE is nil. |
| 293 | The return value has the form (NAME . ADDRESS)." | 291 | The return value has the form (NAME . ADDRESS)." |
| 294 | (save-excursion | 292 | (lm-with-file file |
| 295 | (if file | 293 | (let ((maint (lm-header "maintainer"))) |
| 296 | (find-file file)) | 294 | (if maint |
| 297 | (prog1 | 295 | (lm-crack-address maint) |
| 298 | (let ((maint (lm-header "maintainer"))) | 296 | (car (lm-authors)))))) |
| 299 | (if maint | ||
| 300 | (lm-crack-address maint) | ||
| 301 | (car (lm-authors)))) | ||
| 302 | (if file | ||
| 303 | (kill-buffer (current-buffer))) | ||
| 304 | ))) | ||
| 305 | 297 | ||
| 306 | (defun lm-creation-date (&optional file) | 298 | (defun lm-creation-date (&optional file) |
| 307 | "Return the created date given in file FILE, or current buffer if FILE is nil." | 299 | "Return the created date given in file FILE, or current buffer if FILE is nil." |
| 308 | (save-excursion | 300 | (lm-with-file file |
| 309 | (if file | 301 | (lm-header "created"))) |
| 310 | (find-file file)) | ||
| 311 | (prog1 | ||
| 312 | (lm-header "created") | ||
| 313 | (if file | ||
| 314 | (kill-buffer (current-buffer))) | ||
| 315 | ))) | ||
| 316 | 302 | ||
| 317 | 303 | ||
| 318 | (defun lm-last-modified-date (&optional file) | 304 | (defun lm-last-modified-date (&optional file) |
| 319 | "Return the modify-date given in file FILE, or current buffer if FILE is nil." | 305 | "Return the modify-date given in file FILE, or current buffer if FILE is nil." |
| 320 | (save-excursion | 306 | (lm-with-file file |
| 321 | (if file | 307 | (goto-char (point-min)) |
| 322 | (find-file file)) | 308 | (when (re-search-forward |
| 323 | (prog1 | 309 | "\\$[I]d: [^ ]+ [^ ]+ \\([^/]+\\)/\\([^/]+\\)/\\([^ ]+\\) " |
| 324 | (if (progn | 310 | (lm-code-mark) t) |
| 325 | (goto-char (point-min)) | 311 | (format "%s %s %s" |
| 326 | (re-search-forward | 312 | (buffer-substring (match-beginning 3) (match-end 3)) |
| 327 | "\\$[I]d: [^ ]+ [^ ]+ \\([^/]+\\)/\\([^/]+\\)/\\([^ ]+\\) " | 313 | (nth (string-to-int |
| 328 | (lm-code-mark) t)) | 314 | (buffer-substring (match-beginning 2) (match-end 2))) |
| 329 | (format "%s %s %s" | 315 | '("" "Jan" "Feb" "Mar" "Apr" "May" "Jun" |
| 330 | (buffer-substring (match-beginning 3) (match-end 3)) | 316 | "Jul" "Aug" "Sep" "Oct" "Nov" "Dec")) |
| 331 | (nth (string-to-int | 317 | (buffer-substring (match-beginning 1) (match-end 1)))))) |
| 332 | (buffer-substring (match-beginning 2) (match-end 2))) | ||
| 333 | '("" "Jan" "Feb" "Mar" "Apr" "May" "Jun" | ||
| 334 | "Jul" "Aug" "Sep" "Oct" "Nov" "Dec")) | ||
| 335 | (buffer-substring (match-beginning 1) (match-end 1)) | ||
| 336 | )) | ||
| 337 | (if file | ||
| 338 | (kill-buffer (current-buffer))) | ||
| 339 | ))) | ||
| 340 | 318 | ||
| 341 | (defun lm-version (&optional file) | 319 | (defun lm-version (&optional file) |
| 342 | "Return the version listed in file FILE, or current buffer if FILE is nil. | 320 | "Return the version listed in file FILE, or current buffer if FILE is nil. |
| 343 | This can befound in an RCS or SCCS header to crack it out of." | 321 | This can befound in an RCS or SCCS header to crack it out of." |
| 344 | (save-excursion | 322 | (lm-with-file file |
| 345 | (if file | 323 | (or |
| 346 | (find-file file)) | 324 | (lm-header "version") |
| 347 | (prog1 | 325 | (let ((header-max (lm-code-mark))) |
| 348 | (or | 326 | (goto-char (point-min)) |
| 349 | (lm-header "version") | 327 | (cond |
| 350 | (let ((header-max (lm-code-mark))) | 328 | ;; Look for an RCS header |
| 351 | (goto-char (point-min)) | 329 | ((re-search-forward "\\$[I]d: [^ ]+ \\([^ ]+\\) " header-max t) |
| 352 | (cond | 330 | (buffer-substring-no-properties (match-beginning 1) (match-end 1))) |
| 353 | ;; Look for an RCS header | 331 | |
| 354 | ((re-search-forward "\\$[I]d: [^ ]+ \\([^ ]+\\) " header-max t) | 332 | ;; Look for an SCCS header |
| 355 | (buffer-substring-no-properties (match-beginning 1) (match-end 1))) | 333 | ((re-search-forward |
| 356 | 334 | (concat | |
| 357 | ;; Look for an SCCS header | 335 | (regexp-quote "@(#)") |
| 358 | ((re-search-forward | 336 | (regexp-quote (file-name-nondirectory (buffer-file-name))) |
| 359 | (concat | 337 | "\t\\([012345679.]*\\)") |
| 360 | (regexp-quote "@(#)") | 338 | header-max t) |
| 361 | (regexp-quote (file-name-nondirectory (buffer-file-name))) | 339 | (buffer-substring-no-properties (match-beginning 1) (match-end 1))) |
| 362 | "\t\\([012345679.]*\\)") | 340 | |
| 363 | header-max t) | 341 | (t nil)))))) |
| 364 | (buffer-substring-no-properties (match-beginning 1) (match-end 1))) | ||
| 365 | |||
| 366 | (t nil)))) | ||
| 367 | (if file | ||
| 368 | (kill-buffer (current-buffer))) | ||
| 369 | ))) | ||
| 370 | 342 | ||
| 371 | (defun lm-keywords (&optional file) | 343 | (defun lm-keywords (&optional file) |
| 372 | "Return the keywords given in file FILE, or current buffer if FILE is nil." | 344 | "Return the keywords given in file FILE, or current buffer if FILE is nil." |
| 373 | (save-excursion | 345 | (lm-with-file file |
| 374 | (if file | 346 | (let ((keywords (lm-header "keywords"))) |
| 375 | (find-file file)) | 347 | (and keywords (downcase keywords))))) |
| 376 | (prog1 | ||
| 377 | (let ((keywords (lm-header "keywords"))) | ||
| 378 | (and keywords (downcase keywords))) | ||
| 379 | (if file | ||
| 380 | (kill-buffer (current-buffer))) | ||
| 381 | ))) | ||
| 382 | 348 | ||
| 383 | (defun lm-adapted-by (&optional file) | 349 | (defun lm-adapted-by (&optional file) |
| 384 | "Return the adapted-by names in file FILE, or current buffer if FILE is nil. | 350 | "Return the adapted-by names in file FILE, or current buffer if FILE is nil. |
| 385 | This is the name of the person who cleaned up this package for | 351 | This is the name of the person who cleaned up this package for |
| 386 | distribution." | 352 | distribution." |
| 387 | (save-excursion | 353 | (lm-with-file file |
| 388 | (if file | 354 | (lm-header "adapted-by"))) |
| 389 | (find-file file)) | ||
| 390 | (prog1 | ||
| 391 | (lm-header "adapted-by") | ||
| 392 | (if file | ||
| 393 | (kill-buffer (current-buffer))) | ||
| 394 | ))) | ||
| 395 | 355 | ||
| 396 | (defun lm-commentary (&optional file) | 356 | (defun lm-commentary (&optional file) |
| 397 | "Return the commentary in file FILE, or current buffer if FILE is nil. | 357 | "Return the commentary in file FILE, or current buffer if FILE is nil. |
| 398 | The value is returned as a string. In the file, the commentary starts | 358 | The value is returned as a string. In the file, the commentary starts |
| 399 | with the tag `Commentary' or `Documentation' and ends with one of the | 359 | with the tag `Commentary' or `Documentation' and ends with one of the |
| 400 | tags `Code', `Change Log' or `History'." | 360 | tags `Code', `Change Log' or `History'." |
| 401 | (save-excursion | 361 | (lm-with-file file |
| 402 | (if file | 362 | (let ((commentary (lm-commentary-mark)) |
| 403 | (find-file file)) | 363 | (change-log (lm-history-mark)) |
| 404 | (prog1 | 364 | (code (lm-code-mark))) |
| 405 | (let ((commentary (lm-commentary-mark)) | 365 | (when (and commentary (or change-log code)) |
| 406 | (change-log (lm-history-mark)) | 366 | (buffer-substring-no-properties |
| 407 | (code (lm-code-mark)) | 367 | commentary (min (or code (point-max)) (or change-log (point-max)))))))) |
| 408 | ) | ||
| 409 | (cond | ||
| 410 | ((and commentary change-log) | ||
| 411 | (buffer-substring-no-properties commentary change-log)) | ||
| 412 | ((and commentary code) | ||
| 413 | (buffer-substring-no-properties commentary code)) | ||
| 414 | (t | ||
| 415 | nil))) | ||
| 416 | (if file | ||
| 417 | (kill-buffer (current-buffer))) | ||
| 418 | ))) | ||
| 419 | 368 | ||
| 420 | ;;; Verification and synopses | 369 | ;;; Verification and synopses |
| 421 | 370 | ||
| @@ -457,53 +406,48 @@ a temporary buffer." | |||
| 457 | (lm-insert-at-column lm-comment-column "OK\n"))))))) | 406 | (lm-insert-at-column lm-comment-column "OK\n"))))))) |
| 458 | (directory-files file)) | 407 | (directory-files file)) |
| 459 | )) | 408 | )) |
| 460 | (save-excursion | 409 | (lm-with-file file |
| 461 | (if file | ||
| 462 | (find-file file)) | ||
| 463 | (setq name (lm-get-package-name)) | 410 | (setq name (lm-get-package-name)) |
| 464 | 411 | ||
| 465 | (setq | 412 | (setq |
| 466 | ret | 413 | ret |
| 467 | (prog1 | 414 | (cond |
| 468 | (cond | 415 | ((null name) |
| 469 | ((null name) | 416 | "Can't find a package NAME") |
| 470 | "Can't find a package NAME") | 417 | |
| 471 | 418 | ((not (lm-authors)) | |
| 472 | ((not (lm-authors)) | 419 | "Author: tag missing.") |
| 473 | "Author: tag missing.") | 420 | |
| 474 | 421 | ((not (lm-maintainer)) | |
| 475 | ((not (lm-maintainer)) | 422 | "Maintainer: tag missing.") |
| 476 | "Maintainer: tag missing.") | 423 | |
| 477 | 424 | ((not (lm-summary)) | |
| 478 | ((not (lm-summary)) | 425 | "Can't find a one-line 'Summary' description") |
| 479 | "Can't find a one-line 'Summary' description") | 426 | |
| 480 | 427 | ((not (lm-keywords)) | |
| 481 | ((not (lm-keywords)) | 428 | "Keywords: tag missing.") |
| 482 | "Keywords: tag missing.") | 429 | |
| 483 | 430 | ((not (lm-commentary-mark)) | |
| 484 | ((not (lm-commentary-mark)) | 431 | "Can't find a 'Commentary' section marker.") |
| 485 | "Can't find a 'Commentary' section marker.") | 432 | |
| 486 | 433 | ((not (lm-history-mark)) | |
| 487 | ((not (lm-history-mark)) | 434 | "Can't find a 'History' section marker.") |
| 488 | "Can't find a 'History' section marker.") | 435 | |
| 489 | 436 | ((not (lm-code-mark)) | |
| 490 | ((not (lm-code-mark)) | 437 | "Can't find a 'Code' section marker") |
| 491 | "Can't find a 'Code' section marker") | 438 | |
| 492 | 439 | ((progn | |
| 493 | ((progn | 440 | (goto-char (point-max)) |
| 494 | (goto-char (point-max)) | 441 | (not |
| 495 | (not | 442 | (re-search-backward |
| 496 | (re-search-backward | 443 | (concat "^;;;[ \t]+" name "[ \t]+ends here[ \t]*$" |
| 497 | (concat "^;;;[ \t]+" name "[ \t]+ends here[ \t]*$" | 444 | "\\|^;;;[ \t]+ End of file[ \t]+" name) |
| 498 | "\\|^;;;[ \t]+ End of file[ \t]+" name) | 445 | nil t |
| 499 | nil t | 446 | ))) |
| 500 | ))) | 447 | (format "Can't find a footer line for [%s]" name)) |
| 501 | (format "Can't find a footer line for [%s]" name)) | 448 | (t |
| 502 | (t | 449 | ret)) |
| 503 | ret)) | 450 | ))) |
| 504 | (if file | ||
| 505 | (kill-buffer (current-buffer))) | ||
| 506 | )))) | ||
| 507 | (if verb | 451 | (if verb |
| 508 | (message ret)) | 452 | (message ret)) |
| 509 | ret | 453 | ret |
| @@ -536,14 +480,8 @@ which do not include a recognizable synopsis." | |||
| 536 | (lm-insert-at-column lm-comment-column "NA\n"))))))) | 480 | (lm-insert-at-column lm-comment-column "NA\n"))))))) |
| 537 | (directory-files file)) | 481 | (directory-files file)) |
| 538 | ) | 482 | ) |
| 539 | (save-excursion | 483 | (lm-with-file file |
| 540 | (if file | 484 | (lm-summary)))) |
| 541 | (find-file file)) | ||
| 542 | (prog1 | ||
| 543 | (lm-summary) | ||
| 544 | (if file | ||
| 545 | (kill-buffer (current-buffer))) | ||
| 546 | )))) | ||
| 547 | 485 | ||
| 548 | (defun lm-report-bug (topic) | 486 | (defun lm-report-bug (topic) |
| 549 | "Report a bug in the package currently being visited to its maintainer. | 487 | "Report a bug in the package currently being visited to its maintainer. |