Commit 653d1554 authored by Tassilo Horn's avatar Tassilo Horn
Browse files

2009-11-20 Tassilo Horn <tassilo@member.fsf.org>

	* progmodes/cc-cmds.el (c-update-modeline)
	(c-forward-into-nomenclature, c-backward-into-nomenclature): Refer
	to subword.el functions instead of cc-subword.el.

	* progmodes/cc-mode.el (subword-mode, c-mode-base-map): Refer to
	subword.el functions instead of cc-subword.el.

	* progmodes/cc-subword.el: Renamed to subword.el.
	* subword.el: Renamed from progmodes/cc-subword.el.
	(subword-mode-map): Renamed from c-subword-mode-map.
	(subword-mode): Renamed from c-subword-mode.
	(global-subword-mode): New global minor mode.
	(forward-subword): Renamed from c-forward-subword.
	(backward-subword): Renamed from c-backward-subword.
	(mark-subword): Renamed from c-mark-subword.
	(kill-subword): Renamed from c-kill-subword.
	(backward-kill-subword): Renamed from c-backward-kill-subword.
	(transpose-subwords): Renamed from c-tranpose-subword.
	(downcase-subword): Renamed from c-downcase-subword.
	(capitalize-subword): Renamed from c-capitalize-subword.
	(forward-subword-internal): Renamed from
	c-forward-subword-internal.
	(backward-subword-internal): Renamed from
	c-backward-subword-internal.
parent 8de724f3
2009-11-20 Tassilo Horn <tassilo@member.fsf.org>
* progmodes/cc-cmds.el (c-update-modeline)
(c-forward-into-nomenclature, c-backward-into-nomenclature): Refer
to subword.el functions instead of cc-subword.el.
* progmodes/cc-mode.el (subword-mode, c-mode-base-map): Refer to
subword.el functions instead of cc-subword.el.
* progmodes/cc-subword.el: Renamed to subword.el.
* subword.el: Renamed from progmodes/cc-subword.el.
(subword-mode-map): Renamed from c-subword-mode-map.
(subword-mode): Renamed from c-subword-mode.
(global-subword-mode): New global minor mode.
(forward-subword): Renamed from c-forward-subword.
(backward-subword): Renamed from c-backward-subword.
(mark-subword): Renamed from c-mark-subword.
(kill-subword): Renamed from c-kill-subword.
(backward-kill-subword): Renamed from c-backward-kill-subword.
(transpose-subwords): Renamed from c-tranpose-subword.
(downcase-subword): Renamed from c-downcase-subword.
(capitalize-subword): Renamed from c-capitalize-subword.
(forward-subword-internal): Renamed from
c-forward-subword-internal.
(backward-subword-internal): Renamed from
c-backward-subword-internal.
2009-11-20 Dan Nicolaescu <dann@ics.uci.edu>
* vc.el (vc-deduce-fileset): Allow non-state changing operations
......
......@@ -50,8 +50,6 @@
(cc-bytecomp-defun delete-forward-p) ; XEmacs
(cc-bytecomp-defvar filladapt-mode) ; c-fill-paragraph contains a kludge
; which looks at this.
(cc-bytecomp-defun c-forward-subword)
(cc-bytecomp-defun c-backward-subword)
;; Indentation / Display syntax functions
(defvar c-fix-backslashes t)
......@@ -263,9 +261,9 @@ With universal argument, inserts the analysis as a comment on that line."
"a" "")
(if c-hungry-delete-key "h" "")
(if (and
;; cc-subword might not be loaded.
(boundp 'c-subword-mode)
(symbol-value 'c-subword-mode))
;; subword might not be loaded.
(boundp 'subword-mode)
(symbol-value 'subword-mode))
"w"
"")))
(bare-mode-name (if (string-match "\\(^[^/]*\\)/" mode-name)
......@@ -1328,16 +1326,16 @@ keyword on the line, the keyword is not inserted inside a literal, and
(defun c-forward-into-nomenclature (&optional arg)
"Compatibility alias for `c-forward-subword'."
(interactive "p")
(require 'cc-subword)
(c-forward-subword arg))
(make-obsolete 'c-forward-into-nomenclature 'c-forward-subword "22.1")
(require 'subword)
(forward-subword arg))
(make-obsolete 'c-forward-into-nomenclature 'forward-subword "23.2")
(defun c-backward-into-nomenclature (&optional arg)
"Compatibility alias for `c-backward-subword'."
(interactive "p")
(require 'cc-subword)
(c-backward-subword arg))
(make-obsolete 'c-backward-into-nomenclature 'c-backward-subword "22.1")
(require 'subword)
(backward-subword arg))
(make-obsolete 'c-backward-into-nomenclature 'backward-subword "23.2")
(defun c-scope-operator ()
"Insert a double colon scope operator at point.
......
......@@ -306,9 +306,9 @@ the evaluated constant value at compile time."
:style toggle :selected c-auto-newline]
["Hungry delete" c-toggle-hungry-state
:style toggle :selected c-hungry-delete-key]
["Subword mode" c-subword-mode
:style toggle :selected (and (boundp 'c-subword-mode)
c-subword-mode)])))
["Subword mode" subword-mode
:style toggle :selected (and (boundp 'subword-mode)
subword-mode)])))
;;; Syntax tables.
......
......@@ -113,7 +113,7 @@
;; Autoload directive for emacsen that doesn't have an older CC Mode
;; version in the dist.
(autoload 'c-subword-mode "cc-subword"
(autoload 'subword-mode "subword"
"Mode enabling subword movement and editing keys." t)
;; Load cc-fonts first after font-lock is loaded, since it isn't
......@@ -379,7 +379,7 @@ control). See \"cc-mode.el\" for more info."
;; conflicts with OOBR
;;(define-key c-mode-base-map "\C-c\C-v" 'c-version)
;; (define-key c-mode-base-map "\C-c\C-y" 'c-toggle-hungry-state) Commented out by ACM, 2005-11-22.
(define-key c-mode-base-map "\C-c\C-w" 'c-subword-mode)
(define-key c-mode-base-map "\C-c\C-w" 'subword-mode)
)
;; We don't require the outline package, but we configure it a bit anyway.
......
;;; cc-subword.el --- Handling capitalized subwords in a nomenclature
;;; subword.el --- Handling capitalized subwords in a nomenclature
;; Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009 Free Software Foundation, Inc.
......@@ -21,8 +21,11 @@
;;; Commentary:
;; This package was cc-submode.el before it was recognized being
;; useful in general and not tied to C and c-mode at all.
;; This package provides `subword' oriented commands and a minor mode
;; (`c-subword-mode') that substitutes the common word handling
;; (`subword-mode') that substitutes the common word handling
;; functions with them.
;; In spite of GNU Coding Standards, it is popular to name a symbol by
......@@ -47,15 +50,15 @@
;; Key Word oriented command Subword oriented command
;; ============================================================
;; M-f `forward-word' `c-forward-subword'
;; M-b `backward-word' `c-backward-subword'
;; M-@ `mark-word' `c-mark-subword'
;; M-d `kill-word' `c-kill-subword'
;; M-DEL `backward-kill-word' `c-backward-kill-subword'
;; M-t `transpose-words' `c-transpose-subwords'
;; M-c `capitalize-word' `c-capitalize-subword'
;; M-u `upcase-word' `c-upcase-subword'
;; M-l `downcase-word' `c-downcase-subword'
;; M-f `forward-word' `forward-subword'
;; M-b `backward-word' `backward-subword'
;; M-@ `mark-word' `mark-subword'
;; M-d `kill-word' `kill-subword'
;; M-DEL `backward-kill-word' `backward-kill-subword'
;; M-t `transpose-words' `transpose-subwords'
;; M-c `capitalize-word' `capitalize-subword'
;; M-u `upcase-word' `upcase-subword'
;; M-l `downcase-word' `downcase-subword'
;;
;; Note: If you have changed the key bindings for the word oriented
;; commands in your .emacs or a similar place, the keys you've changed
......@@ -65,7 +68,7 @@
;; your .emacs:
;;
;; (add-hook 'c-mode-common-hook
;; (lambda () (c-subword-mode 1)))
;; (lambda () (subword-mode 1)))
;;
;; Acknowledgment:
......@@ -77,37 +80,22 @@
;;; Code:
(eval-when-compile
(let ((load-path
(if (and (boundp 'byte-compile-dest-file)
(stringp byte-compile-dest-file))
(cons (file-name-directory byte-compile-dest-file) load-path)
load-path)))
(load "cc-bytecomp" nil t)))
(cc-require 'cc-defs)
(cc-require 'cc-cmds)
(defvar c-subword-mode-map
(defvar subword-mode-map
(let ((map (make-sparse-keymap)))
(dolist (cmd '(forward-word backward-word mark-word
kill-word backward-kill-word
transpose-words
(dolist (cmd '(forward-word backward-word mark-word kill-word
backward-kill-word transpose-words
capitalize-word upcase-word downcase-word))
(let ((othercmd (let ((name (symbol-name cmd)))
(string-match "\\(.*-\\)\\(word.*\\)" name)
(intern (concat "c-"
(match-string 1 name)
(intern (concat (match-string 1 name)
"sub"
(match-string 2 name))))))
(if (fboundp 'command-remapping)
(define-key map (vector 'remap cmd) othercmd)
(substitute-key-definition cmd othercmd map global-map))))
(define-key map (vector 'remap cmd) othercmd)))
map)
"Keymap used in command `c-subword-mode' minor mode.")
"Keymap used in `subword-mode' minor mode.")
;;;###autoload
(define-minor-mode c-subword-mode
(define-minor-mode subword-mode
"Mode enabling subword movement and editing keys.
In spite of GNU Coding Standards, it is popular to name a symbol by
mixing uppercase and lowercase letters, e.g. \"GtkWidget\",
......@@ -126,41 +114,45 @@ The subword oriented commands activated in this minor mode recognize
subwords in a nomenclature to move between subwords and to edit them
as words.
\\{c-subword-mode-map}"
\\{subword-mode-map}"
nil
nil
c-subword-mode-map
(c-update-modeline))
subword-mode-map)
(define-obsolete-function-alias 'c-subword-mode 'subword-mode "23.2")
(defun c-forward-subword (&optional arg)
;;;###autoload
(define-global-minor-mode global-subword-mode subword-mode
(lambda () (subword-mode 1)))
(defun forward-subword (&optional arg)
"Do the same as `forward-word' but on subwords.
See the command `c-subword-mode' for a description of subwords.
See the command `subword-mode' for a description of subwords.
Optional argument ARG is the same as for `forward-word'."
(interactive "p")
(unless arg (setq arg 1))
(c-keep-region-active)
(cond
((< 0 arg)
(dotimes (i arg (point))
(c-forward-subword-internal)))
(forward-subword-internal)))
((> 0 arg)
(dotimes (i (- arg) (point))
(c-backward-subword-internal)))
(backward-subword-internal)))
(t
(point))))
(put 'c-forward-subword 'CUA 'move)
(put 'forward-subword 'CUA 'move)
(defun c-backward-subword (&optional arg)
(defun backward-subword (&optional arg)
"Do the same as `backward-word' but on subwords.
See the command `c-subword-mode' for a description of subwords.
See the command `subword-mode' for a description of subwords.
Optional argument ARG is the same as for `backward-word'."
(interactive "p")
(c-forward-subword (- (or arg 1))))
(forward-subword (- (or arg 1))))
(defun c-mark-subword (arg)
(defun mark-subword (arg)
"Do the same as `mark-word' but on subwords.
See the command `c-subword-mode' for a description of subwords.
See the command `subword-mode' for a description of subwords.
Optional argument ARG is the same as for `mark-word'."
;; This code is almost copied from `mark-word' in GNU Emacs.
(interactive "p")
......@@ -168,63 +160,61 @@ Optional argument ARG is the same as for `mark-word'."
(set-mark
(save-excursion
(goto-char (mark))
(c-forward-subword arg)
(forward-subword arg)
(point))))
(t
(push-mark
(save-excursion
(c-forward-subword arg)
(forward-subword arg)
(point))
nil t))))
(put 'c-backward-subword 'CUA 'move)
(put 'backward-subword 'CUA 'move)
(defun c-kill-subword (arg)
(defun kill-subword (arg)
"Do the same as `kill-word' but on subwords.
See the command `c-subword-mode' for a description of subwords.
See the command `subword-mode' for a description of subwords.
Optional argument ARG is the same as for `kill-word'."
(interactive "p")
(kill-region (point) (c-forward-subword arg)))
(kill-region (point) (forward-subword arg)))
(defun c-backward-kill-subword (arg)
(defun backward-kill-subword (arg)
"Do the same as `backward-kill-word' but on subwords.
See the command `c-subword-mode' for a description of subwords.
See the command `subword-mode' for a description of subwords.
Optional argument ARG is the same as for `backward-kill-word'."
(interactive "p")
(c-kill-subword (- arg)))
(kill-subword (- arg)))
(defun c-transpose-subwords (arg)
(defun transpose-subwords (arg)
"Do the same as `transpose-words' but on subwords.
See the command `c-subword-mode' for a description of subwords.
See the command `subword-mode' for a description of subwords.
Optional argument ARG is the same as for `transpose-words'."
(interactive "*p")
(transpose-subr 'c-forward-subword arg))
(transpose-subr 'forward-subword arg))
(defun c-downcase-subword (arg)
(defun downcase-subword (arg)
"Do the same as `downcase-word' but on subwords.
See the command `c-subword-mode' for a description of subwords.
See the command `subword-mode' for a description of subwords.
Optional argument ARG is the same as for `downcase-word'."
(interactive "p")
(let ((start (point)))
(downcase-region (point) (c-forward-subword arg))
(when (< arg 0)
(downcase-region (point) (forward-subword arg))
(when (< arg 0)
(goto-char start))))
(defun c-upcase-subword (arg)
(defun upcase-subword (arg)
"Do the same as `upcase-word' but on subwords.
See the command `c-subword-mode' for a description of subwords.
See the command `subword-mode' for a description of subwords.
Optional argument ARG is the same as for `upcase-word'."
(interactive "p")
(let ((start (point)))
(upcase-region (point) (c-forward-subword arg))
(when (< arg 0)
(upcase-region (point) (forward-subword arg))
(when (< arg 0)
(goto-char start))))
(defun c-capitalize-subword (arg)
(defun capitalize-subword (arg)
"Do the same as `capitalize-word' but on subwords.
See the command `c-subword-mode' for a description of subwords.
See the command `subword-mode' for a description of subwords.
Optional argument ARG is the same as for `capitalize-word'."
(interactive "p")
(let ((count (abs arg))
......@@ -233,13 +223,13 @@ Optional argument ARG is the same as for `capitalize-word'."
(dotimes (i count)
(if advance
(progn (re-search-forward
(concat "[" c-alpha "]")
(concat "[[:alpha:]]")
nil t)
(goto-char (match-beginning 0)))
(c-backward-subword))
(backward-subword))
(let* ((p (point))
(pp (1+ p))
(np (c-forward-subword)))
(np (forward-subword)))
(upcase-region p pp)
(downcase-region pp np)
(goto-char (if advance np p))))
......@@ -251,16 +241,14 @@ Optional argument ARG is the same as for `capitalize-word'."
;;
;; Internal functions
;;
(defun c-forward-subword-internal ()
(defun forward-subword-internal ()
(if (and
(save-excursion
(let ((case-fold-search nil))
(re-search-forward
(concat "\\W*\\(\\([" c-upper "]*\\W?\\)[" c-lower c-digit "]*\\)")
(concat "\\W*\\(\\([[:upper:]]*\\W?\\)[[:lower:][:digit:]]*\\)")
nil t)))
(> (match-end 0) (point))) ; So we don't get stuck at a
; "word-constituent" which isn't c-upper,
; c-lower or c-digit
(> (match-end 0) (point)))
(goto-char
(cond
((< 1 (- (match-end 2) (match-beginning 2)))
......@@ -270,12 +258,12 @@ Optional argument ARG is the same as for `capitalize-word'."
(forward-word 1)))
(defun c-backward-subword-internal ()
(defun backward-subword-internal ()
(if (save-excursion
(let ((case-fold-search nil))
(re-search-backward
(concat
"\\(\\(\\W\\|[" c-lower c-digit "]\\)\\([" c-upper "]+\\W*\\)"
"\\(\\(\\W\\|[[:lower:][:digit:]]\\)\\([[:upper:]]+\\W*\\)"
"\\|\\W\\w+\\)")
nil t)))
(goto-char
......@@ -289,7 +277,6 @@ Optional argument ARG is the same as for `capitalize-word'."
(backward-word 1)))
(cc-provide 'cc-subword)
(provide 'subword)
;; arch-tag: 2be9d294-7f30-4626-95e6-9964bb93c7a3
;;; cc-subword.el ends here
;;; subword.el ends here
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment