Mercurial > hg > xemacs-beta
comparison lisp/simple.el @ 448:3078fd1074e8 r21-2-39
Import from CVS: tag r21-2-39
author | cvs |
---|---|
date | Mon, 13 Aug 2007 11:38:25 +0200 |
parents | 1ccc32a20af4 |
children | 0784d089fdc9 |
comparison
equal
deleted
inserted
replaced
447:4fc5f13f3bd3 | 448:3078fd1074e8 |
---|---|
2542 :type '(choice (const :tag "Use `comment-end'" nil) | 2542 :type '(choice (const :tag "Use `comment-end'" nil) |
2543 string) | 2543 string) |
2544 :group 'fill-comments) | 2544 :group 'fill-comments) |
2545 | 2545 |
2546 (defun indent-for-comment () | 2546 (defun indent-for-comment () |
2547 "Indent this line's comment to comment column, or insert an empty comment." | 2547 "Indent this line's comment to comment column, or insert an empty |
2548 comment. Comments starting in column 0 are not moved." | |
2548 (interactive "*") | 2549 (interactive "*") |
2549 (let* ((empty (save-excursion (beginning-of-line) | 2550 (let* ((empty (save-excursion (beginning-of-line) |
2550 (looking-at "[ \t]*$"))) | 2551 (looking-at "[ \t]*$"))) |
2551 (starter (or (and empty block-comment-start) comment-start)) | 2552 (starter (or (and empty block-comment-start) comment-start)) |
2552 (ender (or (and empty block-comment-end) comment-end))) | 2553 (ender (or (and empty block-comment-end) comment-end))) |
2569 ;; beginning of what was matched. | 2570 ;; beginning of what was matched. |
2570 (skip-syntax-backward " " (match-beginning 0)) | 2571 (skip-syntax-backward " " (match-beginning 0)) |
2571 (skip-syntax-backward "^ " (match-beginning 0))))) | 2572 (skip-syntax-backward "^ " (match-beginning 0))))) |
2572 (setq begpos (point)) | 2573 (setq begpos (point)) |
2573 ;; Compute desired indent. | 2574 ;; Compute desired indent. |
2574 (if (= (current-column) | 2575 ;; XEmacs change: Preserve indentation of comments starting in |
2575 (setq indent (funcall comment-indent-function))) | 2576 ;; column 0, as documented. |
2576 (goto-char begpos) | 2577 (cond |
2578 ((= (current-column) 0) | |
2579 (goto-char begpos)) | |
2580 ((= (current-column) | |
2581 (setq indent (funcall comment-indent-function))) | |
2582 (goto-char begpos)) | |
2583 (t | |
2577 ;; If that's different from current, change it. | 2584 ;; If that's different from current, change it. |
2578 (skip-chars-backward " \t") | 2585 (skip-chars-backward " \t") |
2579 (delete-region (point) begpos) | 2586 (delete-region (point) begpos) |
2580 (indent-to indent)) | 2587 (indent-to indent))) |
2581 ;; An existing comment? | 2588 ;; An existing comment? |
2582 (if cpos | 2589 (if cpos |
2583 (progn (goto-char cpos) | 2590 (progn (goto-char cpos) |
2584 (set-marker cpos nil)) | 2591 (set-marker cpos nil)) |
2585 ;; No, insert one. | 2592 ;; No, insert one. |