Mercurial > emacs
comparison lisp/progmodes/cc-cmds.el @ 18843:6e04c0670f55
Require cc-defs for the c-add-syntax macro.
(c-electric-backspace): Must get 'supercede property
values to work with delsel and pending-del.
(c-electric-brace): Fix ebola eradication consequence
in the preserve-p test.
author | Richard M. Stallman <rms@gnu.org> |
---|---|
date | Fri, 18 Jul 1997 02:10:48 +0000 |
parents | fc6d08b9bbe2 |
children | b573491d7c8f |
comparison
equal
deleted
inserted
replaced
18842:72c2475ece1c | 18843:6e04c0670f55 |
---|---|
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.12 | 10 ;; Version: 5.13 |
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 |
24 | 24 |
25 ;; You should have received a copy of the GNU General Public License | 25 ;; You should have received a copy of the GNU General Public License |
26 ;; along with GNU Emacs; see the file COPYING. If not, write to the | 26 ;; along with GNU Emacs; see the file COPYING. If not, write to the |
27 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330, | 27 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
28 ;; Boston, MA 02111-1307, USA. | 28 ;; Boston, MA 02111-1307, USA. |
29 | |
30 (eval-when-compile | |
31 (require 'cc-defs)) | |
29 | 32 |
30 | 33 |
31 (defun c-calculate-state (arg prevstate) | 34 (defun c-calculate-state (arg prevstate) |
32 ;; Calculate the new state of PREVSTATE, t or nil, based on arg. If | 35 ;; Calculate the new state of PREVSTATE, t or nil, based on arg. If |
33 ;; arg is nil or zero, toggle the state. If arg is negative, turn | 36 ;; arg is nil or zero, toggle the state. If arg is negative, turn |
191 ;; be most disruptive. we'll blink it ourselves later on | 194 ;; be most disruptive. we'll blink it ourselves later on |
192 (old-blink-paren blink-paren-function) | 195 (old-blink-paren blink-paren-function) |
193 blink-paren-function | 196 blink-paren-function |
194 (insertion-point (point)) | 197 (insertion-point (point)) |
195 delete-temp-newline | 198 delete-temp-newline |
196 (preserve-p (eq 32 (char-syntax (char-before)))) | 199 (preserve-p (eq ?\ (char-syntax (char-before)))) |
197 ;; shut this up too | 200 ;; shut this up too |
198 (c-echo-syntactic-information-p nil) | 201 (c-echo-syntactic-information-p nil) |
199 (syntax (progn | 202 (syntax (progn |
200 ;; only insert a newline if there is | 203 ;; only insert a newline if there is |
201 ;; non-whitespace behind us | 204 ;; non-whitespace behind us |
636 (c-keep-region-active)) | 639 (c-keep-region-active)) |
637 | 640 |
638 | 641 |
639 ;; set up electric character functions to work with pending-del, | 642 ;; set up electric character functions to work with pending-del, |
640 ;; (a.k.a. delsel) mode. All symbols get the t value except | 643 ;; (a.k.a. delsel) mode. All symbols get the t value except |
641 ;; c-electric-delete which gets 'supersede. | 644 ;; the functions which delete, which gets 'supersede. |
642 (mapcar | 645 (mapcar |
643 (function | 646 (function |
644 (lambda (sym) | 647 (lambda (sym) |
645 (put sym 'delete-selection t) ; for delsel (Emacs) | 648 (put sym 'delete-selection t) ; for delsel (Emacs) |
646 (put sym 'pending-delete t))) ; for pending-del (XEmacs) | 649 (put sym 'pending-delete t))) ; for pending-del (XEmacs) |
649 c-electric-slash | 652 c-electric-slash |
650 c-electric-star | 653 c-electric-star |
651 c-electric-semi&comma | 654 c-electric-semi&comma |
652 c-electric-lt-gt | 655 c-electric-lt-gt |
653 c-electric-colon)) | 656 c-electric-colon)) |
654 (put 'c-electric-delete 'delete-selection 'supersede) ; delsel | 657 (put 'c-electric-delete 'delete-selection 'supersede) ; delsel |
655 (put 'c-electric-delete 'pending-delete 'supersede) ; pending-del | 658 (put 'c-electric-delete 'pending-delete 'supersede) ; pending-del |
659 (put 'c-electric-backspace 'delete-selection 'supersede) ; delsel | |
660 (put 'c-electric-backspace 'pending-delete 'supersede) ; pending-del | |
656 | 661 |
657 | 662 |
658 ;; This is used by indent-for-comment to decide how much to indent a | 663 ;; This is used by indent-for-comment to decide how much to indent a |
659 ;; comment in C code based on its context. | 664 ;; comment in C code based on its context. |
660 (defun c-comment-indent () | 665 (defun c-comment-indent () |