Skip to content

Commit

Permalink
Remove all workarounds with cua-mode (#2079)
Browse files Browse the repository at this point in the history
  • Loading branch information
Thierry Volpiatto committed Aug 24, 2018
1 parent d5cc641 commit 6505cba
Showing 1 changed file with 3 additions and 22 deletions.
25 changes: 3 additions & 22 deletions helm.el
Original file line number Diff line number Diff line change
Expand Up @@ -2330,16 +2330,14 @@ example, :candidate-number-limit is bound to
For ANY-SOURCES ANY-INPUT ANY-PROMPT ANY-RESUME ANY-PRESELECT ANY-BUFFER and
ANY-KEYMAP ANY-DEFAULT ANY-HISTORY See `helm'."
(unless helm--nested (setq helm-initial-frame (selected-frame)))
;; Activate the advice for `tramp-read-passwd' and cua.
;; Activate the advices.
;; Advices will be available only in >=emacs-24.4, but
;; allow compiling without errors on lower emacs.
(when (fboundp 'advice-add)
(advice-add 'tramp-read-passwd :around #'helm--suspend-read-passwd)
(advice-add 'ange-ftp-get-passwd :around #'helm--suspend-read-passwd)
(advice-add 'epa-passphrase-callback-function
:around #'helm--suspend-read-passwd)
(advice-add 'cua-delete-region :around #'cua-delete-region--advice)
(advice-add 'copy-region-as-kill :around #'copy-region-as-kill--advice))
:around #'helm--suspend-read-passwd))
(helm-log (concat "[Start session] " (make-string 41 ?+)))
(helm-log "any-prompt = %S" any-prompt)
(helm-log "any-preselect = %S" any-preselect)
Expand All @@ -2355,15 +2353,11 @@ ANY-KEYMAP ANY-DEFAULT ANY-HISTORY See `helm'."
focus-follows-mouse
mode-line-in-non-selected-windows
(input-method-verbose-flag helm-input-method-verbose-flag)
(old--cua cua-mode)
(helm--maybe-use-default-as-input
(and (null any-input)
(or helm--maybe-use-default-as-input ; it is let-bounded so use it.
(cl-loop for s in (helm-normalize-sources any-sources)
thereis (memq s helm-sources-using-default-as-input))))))
;; cua-mode override local helm bindings.
;; disable this stupid thing if enabled.
(and cua-mode (cua-mode -1))
(unwind-protect
(condition-case-unless-debug _v
(let ( ;; `helm--source-name' is non-`nil'
Expand Down Expand Up @@ -2409,9 +2403,7 @@ ANY-KEYMAP ANY-DEFAULT ANY-HISTORY See `helm'."
(when (fboundp 'advice-remove)
(advice-remove 'tramp-read-passwd #'helm--suspend-read-passwd)
(advice-remove 'ange-ftp-get-passwd #'helm--suspend-read-passwd)
(advice-remove 'epa-passphrase-callback-function #'helm--suspend-read-passwd)
(advice-remove 'cua-delete-region #'cua-delete-region--advice)
(advice-remove 'copy-region-as-kill #'copy-region-as-kill--advice))
(advice-remove 'epa-passphrase-callback-function #'helm--suspend-read-passwd))
(helm-log "helm-alive-p = %S" (setq helm-alive-p nil))
(helm--remap-mouse-mode -1) ; Reenable mouse bindings.
(setq helm-alive-p nil)
Expand All @@ -2420,7 +2412,6 @@ ANY-KEYMAP ANY-DEFAULT ANY-HISTORY See `helm'."
;; before running helm will not start with its old value.
(setq helm-pattern "")
(setq helm--ignore-errors nil)
(and old--cua (cua-mode 1))
(helm-log-save-maybe))))


Expand Down Expand Up @@ -3290,16 +3281,6 @@ This is used to advice `tramp-read-passwd', `ange-ftp-get-passwd' and
(setq helm--reading-passwd-or-string nil)
(setq helm-suspend-update-flag nil)))

;; CUA workaround
(defun cua-delete-region--advice (old--fn &rest args)
(ignore-errors
(apply old--fn args)))

(defun copy-region-as-kill--advice (old--fn &rest args)
(if cua-mode
(ignore-errors (apply old--fn args))
(apply old--fn args)))

(defun helm--maybe-update-keymap (&optional map)
"Handle different keymaps in multiples sources.

Expand Down

0 comments on commit 6505cba

Please sign in to comment.