branch: externals/ergoemacs-mode commit ba79935528934234dcf9f33b2807244cc302861a Author: Matthew Fidler <514778+mattfid...@users.noreply.github.com> Commit: Matthew Fidler <514778+mattfid...@users.noreply.github.com>
Remove lookup and information about global map --- ergoemacs-advice.el | 3 -- ergoemacs-component.el | 13 +------ ergoemacs-functions.el | 95 +-------------------------------------------- ergoemacs-macros.el | 7 ---- ergoemacs-map-properties.el | 81 +------------------------------------- ergoemacs-map.el | 5 --- ergoemacs-mode.el | 20 +--------- 7 files changed, 4 insertions(+), 220 deletions(-) diff --git a/ergoemacs-advice.el b/ergoemacs-advice.el index 88f73cd..523590d 100644 --- a/ergoemacs-advice.el +++ b/ergoemacs-advice.el @@ -38,19 +38,16 @@ (defvar ergoemacs-mode) (defvar ergoemacs-keymap) (defvar ergoemacs-map--unbound-keys) -(defvar ergoemacs-saved-global-map) (defvar ergoemacs-user-keymap) (declare-function ergoemacs-map-- "ergoemacs-map") (declare-function ergoemacs-map-properties--hook-define-key "ergoemacs-map-properties") -(declare-function ergoemacs-map-properties--ignore-global-changes-p "ergoemacs-map-properties") (declare-function ergoemacs-map-properties--installed-p "ergoemacs-map-properties") (declare-function ergoemacs-map-properties--label "ergoemacs-map-properties") (declare-function ergoemacs-map-properties--map-fixed-plist "ergoemacs-map-properties") (declare-function ergoemacs-map-properties--original "ergoemacs-map-properties") (declare-function ergoemacs-map-properties--original-user "ergoemacs-map-properties") -(declare-function ergoemacs-map-properties--global-submap-p "ergoemacs-map-properties") (declare-function ergoemacs-key-description--substitute-command-keys "ergoemacs-key-description") diff --git a/ergoemacs-component.el b/ergoemacs-component.el index 0590c7f..d4c38f0 100644 --- a/ergoemacs-component.el +++ b/ergoemacs-component.el @@ -48,7 +48,6 @@ (defvar ergoemacs-map-properties--known-maps) (defvar ergoemacs-mode--fast-p) (defvar ergoemacs-mode-version) -(defvar ergoemacs-saved-global-map) (defvar ergoemacs-theme-hash) (defvar ergoemacs-theme-version) (defvar ergoemacs-translate--translation-hash) @@ -86,16 +85,6 @@ ;; ergoemacs-translate -(defcustom ergoemacs-ignore-prev-global t - "If non-nil, the ergoemacs-mode will ignore previously defined global keybindings." - :type 'boolean - :group 'ergoemacs-mode) - -;; for compatability -;;;###autoload -(defun ergoemacs-ignore-prev-global () - "Ignore previously defined global keys." - (setq ergoemacs-ignore-prev-global t)) (defun ergoemacs-remap (function) "Remap the FUNCTION to the appropriate key and then call that function." @@ -251,7 +240,7 @@ OBJ is an `egoemacs-component-struct' object. Returns the map, if it hasn't been initialized, initialize with the label, and then return." (or (ergoemacs-component-struct-map obj) - (let ((map (make-sparse-keymap))) + (let ((map (make-sparse-keymap))) (ergoemacs map :label (list (ergoemacs (ergoemacs :global-map) :key-hash) (intern (format "%s%s" (ergoemacs-component-struct-name obj) (or (ergoemacs-component-struct-version obj) ""))) diff --git a/ergoemacs-functions.el b/ergoemacs-functions.el index 545c2ad..66e5a94 100644 --- a/ergoemacs-functions.el +++ b/ergoemacs-functions.el @@ -1756,99 +1756,6 @@ true; otherwise it is an emacs buffer." (interactive) (text-scale-increase 0)) -;;; helm-mode functions - -;;; This comes from https://github.com/emacs-helm/helm/pull/327, but -;;; was reverted so it is added back here. -(defcustom ergoemacs-helm-ff-ido-style-backspace t - "Use backspace to navigate with `helm-find-files'. -You will have to restart Emacs or reeval `helm-find-files-map' -and `helm-read-file-map' for this to take effect." - :group 'ergoemacs-mode - :type '(choice - (const :tag "Do not use ido-style backspace") - (const :tag "Use ido-style backspace" t))) - -(defun ergoemacs-helm-ff-backspace () - "Call backsapce or `helm-find-files-down-one-level'. -If sitting at the end of a file directory, backspace goes up one -level, like in `ido-find-file'. " - (interactive) - (let (backspace) - (looking-back "^.*" nil) - (cond - ((and ergoemacs-helm-ff-ido-style-backspace - (looking-back "[/\\]" nil)) - (call-interactively - (key-binding (kbd "<left>")))) - (t - (setq backspace (lookup-key - (current-global-map) - (read-kbd-macro "DEL"))) - (call-interactively backspace))))) - - -;;; This comes from https://github.com/emacs-helm/helm/issues/340 -(defcustom ergoemacs-helm-ido-style-return t - "Allows ido-style return in `helm-mode'" - :type 'boolean - :group 'ergoemacs-mode) - -(defun ergoemacs-helm-ff-expand-dir (candidate) - "Allows return to expand a directory like in `ido-find-file'. -This requires `ergoemacs-mode' to be non-nil and -`ergoemacs-helm-ido-style-return' to be non-nil." - (let* ((follow (and (boundp 'helm-follow-mode) - (buffer-local-value - 'helm-follow-mode - (get-buffer-create helm-buffer)))) - (insert-in-minibuffer - #'(lambda (fname) - (with-selected-window (minibuffer-window) - (unless follow - (delete-minibuffer-contents) - (set-text-properties 0 (length fname) - nil fname) - (insert fname)))))) - (if (and ergoemacs-helm-ido-style-return ergoemacs-mode - (file-directory-p candidate)) - (progn - (when (string= (helm-basename candidate) "..") - (setq helm-ff-last-expanded helm-ff-default-directory)) - (funcall insert-in-minibuffer (file-name-as-directory - (expand-file-name candidate)))) - (helm-exit-minibuffer)))) - -(defun ergoemacs-helm-ff-persistent-expand-dir () - "Makes `eroemacs-helm-ff-expand-dir' the default action for -expanding helm-files." - (interactive) - (helm-attrset 'expand-dir 'ergoemacs-helm-ff-expand-dir) - (helm-execute-persistent-action 'expand-dir)) - - -(defun ergoemacs-helm-ff-dired-dir (candidate) - "Determines if a persistent action is called on directories. -When `ergoemacs-mode' is enabled with - `ergoemacs-helm-ido-style-return' non-nil then: -- `helm-execute-persistent-action' is called on files. -- `helm-exit-minibuffer' is called on directories. - -Otherwise `helm-execute-persistent-action' is called. -" - (interactive) - (if (and ergoemacs-helm-ido-style-return ergoemacs-mode - (file-directory-p candidate)) - (helm-exit-minibuffer) - (helm-execute-persistent-action))) - -(defun ergoemacs-helm-ff-execute-dired-dir () - "Allow <M-return> to execute dired on directories in `helm-mode'. -This requires `ergoemacs-mode' to be enabled with -`ergoemacs-helm-ido-style-return' to be non-nil." - (interactive) - (helm-attrset 'dired-dir 'ergoemacs-helm-ff-dired-dir) - (helm-execute-persistent-action 'dired-dir)) ;; (define-key helm-find-files-map (kbd "<M-return>") ;; 'ergoemacs-helm-ff-execute-dired-dir) @@ -2695,7 +2602,7 @@ With a prefix argument like \\[universial-argument] in an key-seq2) (unwind-protect (progn - (setq overriding-terminal-local-map (ergoemacs :original global-map)) + (setq overriding-terminal-local-map global-map) (setq key-seq (read-key-sequence "Old Emacs Command: ") cmd (key-binding key-seq) overriding-terminal-local-map nil diff --git a/ergoemacs-macros.el b/ergoemacs-macros.el index 49b8ef2..2e3dca3 100644 --- a/ergoemacs-macros.el +++ b/ergoemacs-macros.el @@ -231,13 +231,6 @@ When arg1 can be a property. The following properties are supported: ((and arg1 (symbolp arg1) (memq arg1 ergoemacs--map-properties-list)) `(,(intern (format "ergoemacs-map-properties--%s" (substring (symbol-name arg1) 1))) ,@(cdr args))) - - ((and arg1 (symbolp arg1) - (eq arg1 :global-map)) - `(ergoemacs-map-properties--original (or ergoemacs-saved-global-map global-map))) - ((and arg1 (symbolp arg1) - (eq arg1 :revert-global-map)) - `(ergoemacs-map-properties--original (or ergoemacs-saved-global-map global-map) :setcdr)) ((and arg1 (symbolp arg1) (eq arg1 :layout)) `(ergoemacs-layouts--current ,arg2)) diff --git a/ergoemacs-map-properties.el b/ergoemacs-map-properties.el index 2fad276..31d2969 100644 --- a/ergoemacs-map-properties.el +++ b/ergoemacs-map-properties.el @@ -46,9 +46,7 @@ (defvar ergoemacs-directories-where-keys-from-hook-are-deferred) (defvar ergoemacs-functions-that-always-override-ergoemacs-mode) (defvar ergoemacs-hooks-that-always-override-ergoemacs-mode) -(defvar ergoemacs-ignore-prev-global) -(defvar ergoemacs-map--breadcrumb) -(defvar ergoemacs-map-properties--after-ergoemacs) + (defvar ergoemacs-map-properties--after-ergoemacs) (defvar ergoemacs-map-properties--before-ergoemacs) (defvar ergoemacs-map-properties--get-or-generate-map-key) (defvar ergoemacs-map-properties--indirect-keymaps) @@ -277,54 +275,6 @@ When AT-END is non-nil, replace the end of the regular expression with this string. Otherwise, it is assumed to be \"$\".r" (concat (regexp-opt (mapcar (lambda(x) (symbol-name x)) ergoemacs-map-properties--label-atoms-maps) 'symbols) (or (and at-end "$") ""))) -(defun ergoemacs-map-properties--default-global-gen () - "Generate hash for default Emacs maps." - ;; (setq ergoemacs-map-properties--plist-hash (make-hash-table :test 'equal)) - (ergoemacs global-map :label most-negative-fixnum) ;; Should be `most-negative-fixnum' - (push 'global-map ergoemacs-map-properties--label-atoms-maps) - (ergoemacs-map-properties--label-atoms) - (with-temp-file (ergoemacs-map-properties--default-global-file) - (let ((print-level nil) - (print-length nil) - (where-is-hash (make-hash-table)) - tmp - keys) - (goto-char (point-min)) - (insert ";; -*- coding: utf-8-emacs -*-\n") - (insert "(defvar ergoemacs-map-properties--plist-hash)(declare-function ergoemacs-map-properties--label \"ergoemacs-map-properties\")(declare-function ergoemacs-command-loop--spinner-display \"ergoemacs-command-loop\")") - (ergoemacs-map-keymap - (lambda (key item) - (cond - ((vectorp key) - (push key keys) - (if (setq tmp (ergoemacs-gethash item where-is-hash)) - (push key tmp) - (puthash item (list key) where-is-hash))))) - global-map) - (ergoemacs :label global-map) - (ergoemacs :keys global-map) ;; Should calculate :where-is and :lookup from original map - - (insert "(setq ergoemacs-map-properties--plist-hash '") - (prin1 ergoemacs-map-properties--plist-hash (current-buffer)) - (goto-char (point-max)) - (insert ")") - - (insert "(setq ergoemacs-breadcrumb-hash '") - (prin1 ergoemacs-breadcrumb-hash (current-buffer)) - (goto-char (point-max)) - (insert ")") - - (insert "(setq ergoemacs-map-properties--label-atoms-maps '") - (prin1 ergoemacs-map-properties--label-atoms-maps (current-buffer)) - (goto-char (point-max)) - (insert ")") - - (insert "(setq ergoemacs-map-properties--get-or-generate-map-key " - (number-to-string ergoemacs-map-properties--get-or-generate-map-key) ")") - (message "global-map-list %s" (ergoemacs global-map :map-list)) - (message "minibuffer-local-map %s" (ergoemacs minibuffer-local-map :map-list)) - (message "European: %s" (ergoemacs describe-european-environment-map :map-list)) - (message "Completed generating default keys file.")))) (defun ergoemacs-map-properties--label-echo (keymap-symbol map id) "When KEYMAP-SYMBOL is bound, label MAP to ID. @@ -338,11 +288,6 @@ Also let the user know that the labeling was performed." (ergoemacs-warn "%s was not labeled to %s since it was a composed keymap.") (ergoemacs :label (ergoemacs map :original) id))))) - -(defvar ergoemacs-map-properties--global-submap-p nil - "Submap that was found. -The submap is found by the `ergoemacs-map-properties--global-submap-p' function.") - (defun ergoemacs-map-properties--global-submap-p (key) "Determine if KEY is defining a global submap. If so, return the a vector with the key relative to the submap. @@ -629,30 +574,6 @@ These keymaps are saved in `ergoemacs-map-properties--hook-map-hash'." (defvar ergoemacs-map-properties--known-maps nil "A list of known, but unlabeled maps.") -(defun ergoemacs-map-properties--get-original-global-map () - "Load/Create the default global map information." - (if ergoemacs-mode--fast-p - (progn - (setq ergoemacs-map-properties--known-maps ergoemacs-map-properties--label-atoms-maps) - (ergoemacs-map-properties--label-known)) - (ergoemacs-timing get-original-global-map - (if (file-readable-p (ergoemacs-map-properties--default-global-file)) - (progn - (load (ergoemacs-map-properties--default-global-file)) - (setq ergoemacs-map-properties--known-maps ergoemacs-map-properties--label-atoms-maps) - (ergoemacs-map-properties--label-known) - (ergoemacs-map-properties--protect-global-map)) - (if noninteractive - (ergoemacs-warn "Could not find global map information") - (ergoemacs-timing ergoemacs-create-global - (let* ((emacs-exe (ergoemacs-emacs-exe)) - (default-directory (expand-file-name (file-name-directory (locate-library "ergoemacs-mode")))) - (cmd (format "%s -L %s --batch --load \"ergoemacs-mode\" -Q --eval \"(progn (ergoemacs-map-properties--default-global-gen) (kill-emacs))\"" emacs-exe default-directory))) - (message "%s" (shell-command-to-string cmd)) - (ergoemacs-map-properties--get-original-global-map)))))))) - -(add-hook 'ergoemacs-mode-intialize-hook 'ergoemacs-map-properties--get-original-global-map) - (defun ergoemacs-map-properties--map-fixed-plist (keymap) "Determines if this is an `ergoemacs-mode' KEYMAP. Returns a plist of fixed keymap properties (not changed by diff --git a/ergoemacs-map.el b/ergoemacs-map.el index bc7b283..c1f5bf9 100644 --- a/ergoemacs-map.el +++ b/ergoemacs-map.el @@ -82,7 +82,6 @@ (declare-function ergoemacs-map-properties--deferred-maps "ergoemacs-map-properties") (declare-function ergoemacs-map-properties--empty-p "ergoemacs-map-properties") (declare-function ergoemacs-map-properties--get-or-generate-map-key "ergoemacs-map-properties") -(declare-function ergoemacs-map-properties--ignore-global-changes-p "ergoemacs-map-properties") (declare-function ergoemacs-map-properties--installed-p "ergoemacs-map-properties") (declare-function ergoemacs-map-properties--key-hash "ergoemacs-map-properties") (declare-function ergoemacs-map-properties--keymap-value "ergoemacs-map-properties") @@ -298,8 +297,6 @@ done in `ergoemacs-map--alist'." ret)) (defvar ergoemacs-menu-order) -(defvar ergoemacs-map--undefined-keys nil - "List of undefined keys for the global map.") (defvar ergoemacs-map--cache--last-breadcrumb "") @@ -340,8 +337,6 @@ done in `ergoemacs-map--alist'." (defvar ergoemacs-map-- (make-hash-table :test 'equal)) (defvar ergoemacs-map--lookup-hash (make-hash-table :test 'equal)) -(defvar ergoemacs-map--saved-global-map nil) -(defvar ergoemacs-map--last-global-map nil) (defvar ergoemacs-read-from-minibuffer-map nil "If non-nil, keymap that is being read by the minibuffer.") (defvar ergoemacs-map--quit-map nil diff --git a/ergoemacs-mode.el b/ergoemacs-mode.el index d61516d..22b919b 100644 --- a/ergoemacs-mode.el +++ b/ergoemacs-mode.el @@ -139,12 +139,6 @@ Added beginning-of-buffer Alt+n (QWERTY notation) and end-of-buffer Alt+Shift+n" (defvar ergoemacs-translate--parent-map (make-sparse-keymap) "Parent keymap for sparse translation") -(defvar ergoemacs-saved-global-map nil - "Saved global map.") - -(defvar ergoemacs-global-changed-keymap (make-sparse-keymap) - "This keymap shows the global keys that were changed before `ergoemacs-mode' loaded.") - (defvar ergoemacs-map--breadcrumb "" "Breadcrumb that is used to figure out what map is being modified.") @@ -462,14 +456,11 @@ This is structured by valid keyboard layouts for "Hash table of `ergoemacs-mode' timing.") (defvar ergoemacs-timing--locations - '((remove-global-map-map-keymap . "ergoemacs-component.el") - (remove-local-keymap-map-keymap . "ergoemacs-component.el") + '((remove-local-keymap-map-keymap . "ergoemacs-component.el") (translate-keymap . "ergoemacs-component.el") (describe-keymap . "ergoemacs-key-description.el") (before-ergoemacs . "ergoemacs-map-properties.el") - (get-original-global-map . "ergoemacs-map-properties.el") ;; (ergoemacs-map-properties--create-label-function . "ergoemacs-map-properties.el") - (ergoemacs-create-global . "ergoemacs-map-properties.el") (empty-p . "ergoemacs-map-properties.el") (where-is-hash . "ergoemacs-map-properties.el") (flatten-original . "ergoemacs-map-properties.el") @@ -794,15 +785,6 @@ Valid values are: :initialize #'custom-initialize-default :group 'ergoemacs-mode) -(defvar ergoemacs-map-properties--global-map-before-ergoemacs (ergoemacs-map-keymap nil global-map) - "A single keymap for the keys before `ergoemacs-mode' loads.") - -(defcustom ergoemacs-ignore-prev-global t - "Ignore global keys that were changed before `ergoemacs-mode' was loaded." - :type 'boolean - :set #'ergoemacs-set-default - :initialize #'custom-initialize-default - :group 'ergoemacs-mode) (defgroup ergoemacs-display nil "Display Options for `ergoemacs-mode'."