Mercurial > emacs
comparison lisp/newcomment.el @ 57301:800ede9cd8e3
comment-beginning: doc-fix and don't choke on unset comment-end-skip when at beginning of comment
author | Daniel Pfeiffer <occitan@esperanto.org> |
---|---|
date | Sun, 03 Oct 2004 15:33:38 +0000 |
parents | 902c984fa20a |
children | d0bca414ad07 58db929d96c6 |
comparison
equal
deleted
inserted
replaced
57300:4f118650fb0c | 57301:800ede9cd8e3 |
---|---|
421 cs)))) | 421 cs)))) |
422 | 422 |
423 (defun comment-beginning () | 423 (defun comment-beginning () |
424 "Find the beginning of the enclosing comment. | 424 "Find the beginning of the enclosing comment. |
425 Returns nil if not inside a comment, else moves point and returns | 425 Returns nil if not inside a comment, else moves point and returns |
426 the same as `comment-search-forward'." | 426 the same as `comment-search-backward'." |
427 ;; HACK ATTACK! | 427 ;; HACK ATTACK! |
428 ;; We should really test `in-string-p' but that can be expensive. | 428 ;; We should really test `in-string-p' but that can be expensive. |
429 (unless (eq (get-text-property (point) 'face) 'font-lock-string-face) | 429 (unless (eq (get-text-property (point) 'face) 'font-lock-string-face) |
430 (let ((pt (point)) | 430 (let ((pt (point)) |
431 (cs (comment-search-backward nil t))) | 431 (cs (comment-search-backward nil t))) |
433 (if (save-excursion | 433 (if (save-excursion |
434 (goto-char cs) | 434 (goto-char cs) |
435 (and | 435 (and |
436 ;; For modes where comment-start and comment-end are the same, | 436 ;; For modes where comment-start and comment-end are the same, |
437 ;; the search above may have found a `ce' rather than a `cs'. | 437 ;; the search above may have found a `ce' rather than a `cs'. |
438 (or (not (looking-at comment-end-skip)) | 438 (or (if comment-end-skip (not (looking-at comment-end-skip))) |
439 ;; Maybe font-lock knows that it's a `cs'? | 439 ;; Maybe font-lock knows that it's a `cs'? |
440 (eq (get-text-property (match-end 0) 'face) | 440 (eq (get-text-property (match-end 0) 'face) |
441 'font-lock-comment-face) | 441 'font-lock-comment-face) |
442 (unless (eq (get-text-property (point) 'face) | 442 (unless (eq (get-text-property (point) 'face) |
443 'font-lock-comment-face) | 443 'font-lock-comment-face) |