]> code.delx.au - gnu-emacs/blobdiff - lisp/progmodes/cc-cmds.el
More-conservative ‘format’ quote restyling
[gnu-emacs] / lisp / progmodes / cc-cmds.el
index 55b676b1d9f2b535c878f0503ec0541cff15fbe3..0e249bd4212511680fc9d3209bc79de2b0c43b71 100644 (file)
@@ -1,6 +1,6 @@
 ;;; cc-cmds.el --- user level commands for CC Mode
 
-;; Copyright (C) 1985, 1987, 1992-2014 Free Software Foundation, Inc.
+;; Copyright (C) 1985, 1987, 1992-2015 Free Software Foundation, Inc.
 
 ;; Authors:    2003- Alan Mackenzie
 ;;             1998- Martin Stjernholm
@@ -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
@@ -1304,6 +1306,20 @@ 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)))
+
+(declare-function c-forward-subword "ext:cc-subword" (&optional arg))
+(declare-function c-backward-subword "ext:cc-subword" (&optional arg))
+
 ;; "nomenclature" functions + c-scope-operator.
 (defun c-forward-into-nomenclature (&optional arg)
   "Compatibility alias for `c-forward-subword'."
@@ -1793,7 +1809,7 @@ with a brace block."
   (c-save-buffer-state
       (beginning-of-defun-function end-of-defun-function
        where pos name-end case-fold-search)
+
     (save-restriction
       (widen)
       (save-excursion
@@ -2837,19 +2853,28 @@ sentence motion in or near comments and multiline strings."
 \f
 ;; set up electric character functions to work with pending-del,
 ;; (a.k.a. delsel) mode.  All symbols get the t value except
-;; the functions which delete, which gets 'supersede.
+;; the functions which delete, which gets 'supersede, and (from Emacs
+;; 25) `c-electric-brace' and `c-electric-paren' get special handling
+;; so as to work gracefully with `electric-pair-mode'.
 (mapc
  (function
   (lambda (sym)
     (put sym 'delete-selection t)      ; for delsel (Emacs)
     (put sym 'pending-delete t)))      ; for pending-del (XEmacs)
  '(c-electric-pound
-   c-electric-brace
    c-electric-slash
    c-electric-star
    c-electric-semi&comma
    c-electric-lt-gt
-   c-electric-colon
+   c-electric-colon))
+(mapc
+ (function
+  (lambda (sym)
+    (put sym 'delete-selection (if (fboundp 'delete-selection-uses-region-p)
+                                  'delete-selection-uses-region-p
+                                t))
+    (put sym 'pending-delete t)))
+ '(c-electric-brace
    c-electric-paren))
 (put 'c-electric-delete    'delete-selection 'supersede) ; delsel
 (put 'c-electric-delete    'pending-delete   'supersede) ; pending-del
@@ -3396,7 +3421,7 @@ Otherwise reindent just the current line."
       (if (< c-progress-interval (- now lastsecs))
          (progn
            (message "Indenting region... (%d%% complete)"
-                    (/ (* 100 (- (point) start)) (- end start)))
+                    (floor (* 100.0 (- (point) start)) (- end start)))
            (aset c-progress-info 2 now)))
       )))
 
@@ -4744,8 +4769,8 @@ normally bound to C-o.  See `c-context-line-break' for the details."
 \f
 (cc-provide 'cc-cmds)
 
-;;; Local Variables:
-;;; indent-tabs-mode: t
-;;; tab-width: 8
-;;; End:
+;; Local Variables:
+;; indent-tabs-mode: t
+;; tab-width: 8
+;; End:
 ;;; cc-cmds.el ends here