diff options
Diffstat (limited to 'lisp/progmodes/cc-cmds.el')
-rw-r--r-- | lisp/progmodes/cc-cmds.el | 82 |
1 files changed, 58 insertions, 24 deletions
diff --git a/lisp/progmodes/cc-cmds.el b/lisp/progmodes/cc-cmds.el index 4f205d62a4c..0724697f8e8 100644 --- a/lisp/progmodes/cc-cmds.el +++ b/lisp/progmodes/cc-cmds.el @@ -258,9 +258,11 @@ With universal argument, inserts the analysis as a comment on that line." "a" "") (if c-hungry-delete-key "h" "") (if (and - ;; subword might not be loaded. - (boundp 'subword-mode) - (symbol-value 'subword-mode)) + ;; (cc-)subword might not be loaded. + (boundp 'c-subword-mode) + (symbol-value 'c-subword-mode)) + ;; FIXME: subword-mode already comes with its + ;; own lighter! "w" ""))) ;; FIXME: Derived modes might want to use something else @@ -1090,7 +1092,7 @@ numeric argument is supplied, or the point is inside a literal." (interactive "*P") (let ((c-echo-syntactic-information-p nil) - final-pos close-paren-inserted found-delim case-fold-search) + final-pos found-delim case-fold-search) (self-insert-command (prefix-numeric-value arg)) (setq final-pos (point)) @@ -1155,11 +1157,12 @@ numeric argument is supplied, or the point is inside a literal." (when (and (eq (char-before) ?>) (not executing-kbd-macro) blink-paren-function) - ;; Note: Most paren blink functions, such as the standard - ;; `blink-matching-open', currently doesn't handle paren chars - ;; marked with text properties very well. Maybe we should avoid - ;; this call for the time being? - (funcall blink-paren-function))))) + ;; Currently (2014-10-19), the syntax-table text properties on < and > + ;; are only applied in code called during Emacs redisplay. We thus + ;; explicitly cause a redisplay so that these properties have been + ;; applied when `blink-paren-function' gets called. + (sit-for 0) + (funcall blink-paren-function))))) (defun c-electric-paren (arg) "Insert a parenthesis. @@ -1303,20 +1306,43 @@ keyword on the line, the keyword is not inserted inside a literal, and (declare-function subword-forward "subword" (&optional arg)) (declare-function subword-backward "subword" (&optional arg)) +(cond + ((and (fboundp 'subword-mode) (not (fboundp 'c-subword-mode))) + ;; Recent Emacsen come with their own subword support. Use that. + (define-obsolete-function-alias 'c-subword-mode 'subword-mode "24.3") + (define-obsolete-variable-alias 'c-subword-mode 'subword-mode "24.3")) + (t + ;; Autoload directive for emacsen that doesn't have an older CC Mode + ;; version in the dist. + (autoload 'c-subword-mode "cc-subword" + "Mode enabling subword movement and editing keys." t))) + ;; "nomenclature" functions + c-scope-operator. (defun c-forward-into-nomenclature (&optional arg) "Compatibility alias for `c-forward-subword'." (interactive "p") - (require 'subword) - (subword-forward arg)) -(make-obsolete 'c-forward-into-nomenclature 'subword-forward "23.2") + (if (fboundp 'subword-mode) + (progn + (require 'subword) + (subword-forward arg)) + (require 'cc-subword) + (c-forward-subword arg))) +(make-obsolete 'c-forward-into-nomenclature + (if (fboundp 'subword-mode) 'subword-forward 'c-forward-subword) + "23.2") (defun c-backward-into-nomenclature (&optional arg) "Compatibility alias for `c-backward-subword'." (interactive "p") - (require 'subword) - (subword-backward arg)) -(make-obsolete 'c-backward-into-nomenclature 'subword-backward "23.2") + (if (fboundp 'subword-mode) + (progn + (require 'subword) + (subword-backward arg)) + (require 'cc-subword) + (c-backward-subword arg))) +(make-obsolete + 'c-backward-into-nomenclature + (if (fboundp 'subword-mode) 'subword-backward 'c-backward-subword) "23.2") (defun c-scope-operator () "Insert a double colon scope operator at point. @@ -1416,12 +1442,15 @@ No indentation or other \"electric\" behavior is performed." (car (c-beginning-of-decl-1 ;; NOTE: If we're in a K&R region, this might be the start ;; of a parameter declaration, not the actual function. + ;; It might also leave us at a label or "label" like + ;; "private:". (and least-enclosing ; LIMIT for c-b-of-decl-1 (c-safe-position least-enclosing paren-state))))) ;; Has the declaration we've gone back to got braces? - (setq brace-decl-p - (save-excursion + (or (eq decl-result 'label) + (setq brace-decl-p + (save-excursion (and (c-syntactic-re-search-forward "[;{]" nil t t) (or (eq (char-before) ?\{) (and c-recognize-knr-p @@ -1429,10 +1458,11 @@ No indentation or other \"electric\" behavior is performed." ;; ';' in a K&R argdecl. In ;; that case the declaration ;; should contain a block. - (c-in-knr-argdecl)))))) + (c-in-knr-argdecl))))))) (cond - ((= (point) kluge-start) ; might be BOB or unbalanced parens. + ((or (eq decl-result 'label) ; e.g. "private:" or invalid syntax. + (= (point) kluge-start)) ; might be BOB or unbalanced parens. 'outwith-function) ((eq decl-result 'same) (if brace-decl-p @@ -1580,7 +1610,7 @@ defun." (or (not (eq this-command 'c-beginning-of-defun)) (eq last-command 'c-beginning-of-defun) - (and transient-mark-mode mark-active) + (c-region-is-active-p) (push-mark)) (c-save-buffer-state @@ -1704,7 +1734,7 @@ the open-parenthesis that starts a defun; see `beginning-of-defun'." (or (not (eq this-command 'c-end-of-defun)) (eq last-command 'c-end-of-defun) - (and transient-mark-mode mark-active) + (c-region-is-active-p) (push-mark)) (c-save-buffer-state @@ -1808,7 +1838,7 @@ with a brace block." (looking-at c-symbol-key)) (match-string-no-properties 0)) - ((looking-at "DEFUN\\_>") + ((looking-at "DEFUN\\s-*(") ;"DEFUN\\_>") think of XEmacs! ;; DEFUN ("file-name-directory", Ffile_name_directory, Sfile_name_directory, ...) ==> Ffile_name_directory ;; DEFUN(POSIX::STREAM-LOCK, stream lockp &key BLOCK SHARED START LENGTH) ==> POSIX::STREAM-LOCK (down-list 1) @@ -2001,7 +2031,7 @@ function does not require the declaration to contain a brace block." (eq last-command 'c-mark-function))) (push-mark-p (and (eq this-command 'c-mark-function) (not extend-region-p) - (not (and transient-mark-mode mark-active))))) + (not (c-region-is-active-p))))) (if push-mark-p (push-mark (point))) (if extend-region-p (progn @@ -3338,7 +3368,7 @@ Otherwise, with a prefix argument, rigidly reindent the expression starting on the current line. Otherwise reindent just the current line." (interactive - (list current-prefix-arg (use-region-p))) + (list current-prefix-arg (c-region-is-active-p))) (if region (c-indent-region (region-beginning) (region-end)) (c-indent-command arg))) @@ -4727,4 +4757,8 @@ normally bound to C-o. See `c-context-line-break' for the details." (cc-provide 'cc-cmds) +;;; Local Variables: +;;; indent-tabs-mode: t +;;; tab-width: 8 +;;; End: ;;; cc-cmds.el ends here |