+2013-12-08 Stefan Monnier <monnier@iro.umontreal.ca>
+
+ * emulation/cua-rect.el (cua--rectangle-highlight-for-redisplay):
+ New function.
+ (redisplay-highlight-region-function): Use it.
+
+ * emulation/cua-base.el (cua--explicit-region-start)
+ (cua--last-region-shifted): Remove.
+ (cua--deactivate): Use deactivate-mark.
+ (cua--pre-command-handler-1): Don't handle shift-selection.
+ (cua--post-command-handler-1): Don't change transient-mark-mode.
+ (cua--select-keymaps): Use region-active-p rather than
+ cua--explicit-region-start or cua--last-region-shifted.
+ (cua-mode): Enable shift-select-mode.
+
2013-12-08 Leo Liu <sdl.web@gmail.com>
- * progmodes/flymake.el (flymake-popup-current-error-menu): Rename
- from flymake-display-err-menu-for-current-line. Reimplement.
+ * progmodes/flymake.el (flymake-popup-current-error-menu):
+ Rename from flymake-display-err-menu-for-current-line. Reimplement.
(flymake-posn-at-point-as-event, flymake-popup-menu)
(flymake-make-emacs-menu): Remove. (Bug#16077)
;;; Aux. variables
-;; Current region was started using cua-set-mark.
-(defvar cua--explicit-region-start nil)
-(make-variable-buffer-local 'cua--explicit-region-start)
-
-;; Latest region was started using shifted movement command.
-(defvar cua--last-region-shifted nil)
-
;; buffer + point prior to current command when rectangle is active
;; checked in post-command hook to see if point was moved
(defvar cua--buffer-and-point-before-command nil)
deactivate-mark nil))
(defun cua--deactivate (&optional now)
- (setq cua--explicit-region-start nil)
(if (not now)
(setq deactivate-mark t)
- (setq mark-active nil)
- (run-hooks 'deactivate-mark-hook)))
+ (deactivate-mark)))
(defun cua--filter-buffer-noprops (start end)
(let ((str (filter-buffer-substring start end)))
"Cancel the active region, rectangle, or global mark."
(interactive)
(setq mark-active nil)
- (setq cua--explicit-region-start nil)
(if (fboundp 'cua--cancel-rectangle)
(cua--cancel-rectangle)))
(message "Mark cleared"))
(t
(push-mark-command nil nil)
- (setq cua--explicit-region-start t)
- (setq cua--last-region-shifted nil)
(if cua-enable-region-auto-help
(cua-help-for-region t)))))
((not (eq (get this-command 'CUA) 'move))
nil)
- ;; Handle shifted cursor keys and other movement commands.
- ;; If region is not active, region is activated if key is shifted.
- ;; If region is active, region is canceled if key is unshifted
- ;; (and region not started with C-SPC).
- ;; If rectangle is active, expand rectangle in specified direction and
- ;; ignore the movement.
- (this-command-keys-shift-translated
- (unless mark-active
- (push-mark-command nil t))
- (setq cua--last-region-shifted t)
- (setq cua--explicit-region-start nil))
-
;; Set mark if user explicitly said to do so
- ((or cua--explicit-region-start cua--rectangle)
+ (cua--rectangle ;FIXME: ??
(unless mark-active
- (push-mark-command nil nil)))
-
- ;; Else clear mark after this command.
- (t
- ;; If we set mark-active to nil here, the region highlight will not be
- ;; removed by the direct_output_ commands.
- (setq deactivate-mark t)))
+ (push-mark-command nil nil))))
;; Detect extension of rectangles by mouse or other movement
(setq cua--buffer-and-point-before-command
(when (fboundp 'cua--rectangle-post-command)
(cua--rectangle-post-command))
(setq cua--buffer-and-point-before-command nil)
- (if (or (not mark-active) deactivate-mark)
- (setq cua--explicit-region-start nil))
;; Debugging
(if cua--debug
(cond
(cua--rectangle (cua--rectangle-assert))
- (mark-active (message "Mark=%d Point=%d Expl=%s"
- (mark t) (point) cua--explicit-region-start))))
-
- ;; Disable transient-mark-mode if rectangle active in current buffer.
- (if (not (window-minibuffer-p))
- (setq transient-mark-mode (and (not cua--rectangle)
- (if cua-highlight-region-shift-only
- (not cua--explicit-region-start)
- t))))
+ (mark-active (message "Mark=%d Point=%d" (mark t) (point)))))
+
(if cua-enable-cursor-indications
(cua--update-indications))
cua-enable-cua-keys
(not cua-inhibit-cua-keys)
(or (eq cua-enable-cua-keys t)
- (not cua--explicit-region-start))
+ (region-active-p))
(not executing-kbd-macro)
(not cua--prefix-override-timer)))
(setq cua--ena-prefix-repeat-keymap
(and cua-enable-cua-keys
(not cua-inhibit-cua-keys)
(or (eq cua-enable-cua-keys t)
- cua--last-region-shifted)))
+ (region-active-p))))
(setq cua--ena-global-mark-keymap
(and cua--global-mark-active
(not (window-minibuffer-p)))))
(if (and (boundp 'pc-selection-mode) pc-selection-mode)
(pc-selection-mode -1))
(cua--deactivate)
- (setq shift-select-mode nil)
- (setq transient-mark-mode (and cua-mode
- (if cua-highlight-region-shift-only
- (not cua--explicit-region-start)
- t))))
+ (setq shift-select-mode t)
+ (transient-mark-mode (if cua-highlight-region-shift-only -1 1)))
(cua--saved-state
(setq transient-mark-mode (car cua--saved-state))
(if (nth 1 cua--saved-state)
(push-mark nil nil t)))
(cua--activate-rectangle)
(cua--rectangle-set-corners)
- (setq mark-active t
- cua--explicit-region-start t)
+ (setq mark-active t)
(if cua-enable-rectangle-auto-help
(cua-help-for-rectangle t))))
"Cancel current rectangle."
(interactive)
(when cua--rectangle
- (setq mark-active nil
- cua--explicit-region-start nil)
+ (setq mark-active nil)
(cua--deactivate-rectangle)))
(defun cua-toggle-rectangle-mark ()
(add-function :around region-extract-function
#'cua--rectangle-region-extract)
+(add-function :around redisplay-highlight-region-function
+ #'cua--rectangle-highlight-for-redisplay)
+
+(defun cua--rectangle-highlight-for-redisplay (orig &rest args)
+ (if (not cua--rectangle) (apply orig args)
+ ;; When cua--rectangle is active, just don't highlight at all, since we
+ ;; already do it elsewhere.
+ ))
(defun cua--rectangle-region-extract (orig &optional delete)
(cond