Mercurial > hg > xemacs-beta
comparison lisp/cc-mode/cc-cmds.el @ 181:bfd6434d15b3 r20-3b17
Import from CVS: tag r20-3b17
author | cvs |
---|---|
date | Mon, 13 Aug 2007 09:53:19 +0200 |
parents | 6075d714658b |
children | e121b013d1f0 |
comparison
equal
deleted
inserted
replaced
180:add28d59e586 | 181:bfd6434d15b3 |
---|---|
5 ;; Authors: 1992-1997 Barry A. Warsaw | 5 ;; Authors: 1992-1997 Barry A. Warsaw |
6 ;; 1987 Dave Detlefs and Stewart Clamen | 6 ;; 1987 Dave Detlefs and Stewart Clamen |
7 ;; 1985 Richard M. Stallman | 7 ;; 1985 Richard M. Stallman |
8 ;; Maintainer: cc-mode-help@python.org | 8 ;; Maintainer: cc-mode-help@python.org |
9 ;; Created: 22-Apr-1997 (split from cc-mode.el) | 9 ;; Created: 22-Apr-1997 (split from cc-mode.el) |
10 ;; Version: 5.14 | 10 ;; Version: 5.15 |
11 ;; Keywords: c languages oop | 11 ;; Keywords: c languages oop |
12 | 12 |
13 ;; This file is part of GNU Emacs. | 13 ;; This file is part of GNU Emacs. |
14 | 14 |
15 ;; GNU Emacs is free software; you can redistribute it and/or modify | 15 ;; GNU Emacs is free software; you can redistribute it and/or modify |
352 (funcall old-blink-paren))) | 352 (funcall old-blink-paren))) |
353 )))) | 353 )))) |
354 | 354 |
355 (defun c-electric-slash (arg) | 355 (defun c-electric-slash (arg) |
356 "Insert a slash character. | 356 "Insert a slash character. |
357 If slash is second of a double-slash C++ style comment introducing | 357 |
358 construct, and we are on a comment-only-line, indent line as comment. | 358 Indent the line as a comment, if: |
359 | |
360 1. The slash is second of a `//' line oriented comment introducing | |
361 token and we are on a comment-only-line, or | |
362 | |
363 2. The slash is part of a `*/' token that closes a block oriented | |
364 comment. | |
365 | |
359 If numeric ARG is supplied or point is inside a literal, indentation | 366 If numeric ARG is supplied or point is inside a literal, indentation |
360 is inhibited." | 367 is inhibited." |
361 (interactive "P") | 368 (interactive "P") |
362 (let ((indentp (and (not arg) | 369 (let* ((ch (char-before)) |
363 (eq (char-before) ?/) | 370 (indentp (and (not arg) |
364 (eq last-command-char ?/) | 371 (eq last-command-char ?/) |
365 (not (c-in-literal)))) | 372 (or (and (eq ch ?/) |
366 ;; shut this up | 373 (not (c-in-literal))) |
367 (c-echo-syntactic-information-p nil)) | 374 (and (eq ch ?*) |
375 (c-in-literal))) | |
376 )) | |
377 ;; shut this up | |
378 (c-echo-syntactic-information-p nil)) | |
368 (self-insert-command (prefix-numeric-value arg)) | 379 (self-insert-command (prefix-numeric-value arg)) |
369 (if indentp | 380 (if indentp |
370 (c-indent-line)))) | 381 (c-indent-line)))) |
371 | 382 |
372 (defun c-electric-star (arg) | 383 (defun c-electric-star (arg) |
732 ;; CASE 6: indent at comment column except leave at least one | 743 ;; CASE 6: indent at comment column except leave at least one |
733 ;; space. | 744 ;; space. |
734 (t (max (1+ (current-column)) | 745 (t (max (1+ (current-column)) |
735 comment-column)) | 746 comment-column)) |
736 ))))) | 747 ))))) |
748 | |
749 ;; for proposed new variable comment-line-break-function | |
750 (defun c-comment-line-break-function (&optional soft) | |
751 ;; we currently don't do anything with soft line breaks | |
752 (if (not c-comment-continuation-stars) | |
753 (indent-new-comment-line soft) | |
754 (let ((here (point)) | |
755 (leader c-comment-continuation-stars)) | |
756 (back-to-indentation) | |
757 ;; are we looking at a block or lines style comment? | |
758 (if (and (looking-at (concat "\\(" c-comment-start-regexp "\\)[ \t]+")) | |
759 (string-equal (match-string 1) "//")) | |
760 ;; line style | |
761 (setq leader "// ")) | |
762 (goto-char here) | |
763 (delete-region (progn (skip-chars-backward " \t") (point)) | |
764 (progn (skip-chars-forward " \t") (point))) | |
765 (newline) | |
766 ;; to avoid having an anchored comment that c-indent-line will | |
767 ;; trip up on | |
768 (insert " " leader) | |
769 (c-indent-line)))) | |
770 | |
771 ;; advice for indent-new-comment-line for older Emacsen | |
772 (if (boundp 'comment-line-break-function) | |
773 nil | |
774 (require 'advice) | |
775 (defadvice indent-new-comment-line (around c-line-break-advice activate) | |
776 (if (or (not c-buffer-is-cc-mode) | |
777 (not c-comment-continuation-stars)) | |
778 ad-do-it | |
779 (c-comment-line-break-function (ad-get-arg 0))))) | |
737 | 780 |
738 ;; used by outline-minor-mode | 781 ;; used by outline-minor-mode |
739 (defun c-outline-level () | 782 (defun c-outline-level () |
740 (save-excursion | 783 (save-excursion |
741 (skip-chars-forward "\t ") | 784 (skip-chars-forward "\t ") |