Open seagle0128 opened 4 years ago
In README - key-binding remap example is here
(use-package unfill
:bind ([remap fill-paragraph] . unfill-toggle))
I'll bit change it to suit your situation.
(use-package go-mode
:bind (:map go-mode-map
([remap xref-find-definitions] . nil)))
macroexpand use-package
(pp
(let ((use-package-expand-minimally t))
(macroexpand-1
'(use-package go-mode
:bind (:map go-mode-map
([remap xref-find-definitions] . nil))))))
;;=> (progn
;; (require 'go-mode nil nil)
;; (bind-keys :package go-mode :map go-mode-map
;; ([remap xref-find-definitions])))
and macroexpand bind-keys
(pp
(let ((use-package-expand-minimally t))
(macroexpand-1
'(bind-keys :package go-mode :map go-mode-map
([remap xref-find-definitions])))))
;;=> (if (boundp 'go-mode-map)
;; (bind-key [remap xref-find-definitions] nil go-mode-map nil)
;; (eval-after-load 'go-mode
;; '(bind-key
;; [remap xref-find-definitions]
;; nil go-mode-map nil)))
BTW, macroexpand unbind-key
(pp
(macroexpand-1
'(unbind-key ([remap xref-find-definitions]) go-mode-map)))
;;=> (progn
;; (bind-key ([remap xref-find-definitions]) nil go-mode-map)
;; (setq personal-keybindings
;; (cl-delete-if
;; #'(lambda (k)
;; (and (consp (car k))
;; (string= (caar k) ([remap xref-find-definitions]))
;; (eq (cdar k) 'go-mode-map)))
;; personal-keybindings)))
(pp
(macroexpand-1
'(unbind-key [remap xref-find-definitions] go-mode-map)))
;;=> (progn
;; (bind-key [remap xref-find-definitions] nil go-mode-map)
;; (setq personal-keybindings
;; (cl-delete-if
;; #'(lambda (k)
;; (and (consp (car k))
;; (string= (caar k) [remap xref-find-definitions])
;; (eq (cdar k) 'go-mode-map)))
;; personal-keybindings)))
As this result, you would use unbind-key
like below but this sexp also error :)
(unbind-key [remap xref-find-definitions] go-mode-map)
Debugger entered--Lisp error: (wrong-type-argument stringp [remap xref-find-definitions])
string=("<remap> <fill-paragraph>" [remap xref-find-definitions])
(and (consp (car k)) (string= (car (car k)) [remap xref-find-definitions]) (eq (cdr (car k)) (quote go-mode-map)))
(lambda (k) (and (consp (car k)) (string= (car (car k)) [remap xref-find-definitions]) (eq (cdr (car k)) (quote go-mode-map))))((("<remap> <fill-paragraph>") nil nil))
cl-delete(nil ((("<remap> <fill-paragraph>") nil nil) (("<remap> <xref-find-definitions>" . go-mode-map) nil nil)) :if (lambda (k) (and (consp (car k)) (string= (car (car k)) [remap xref-find-definitions]) (eq (cdr (car k)) (quote go-mode-map)))))
apply(cl-delete nil ((("<remap> <fill-paragraph>") nil nil) (("<remap> <xref-find-definitions>" . go-mode-map) nil nil)) :if (lambda (k) (and (consp (car k)) (string= (car (car k)) [remap xref-find-definitions]) (eq (cdr (car k)) (quote go-mode-map)))) nil)
cl-delete-if((lambda (k) (and (consp (car k)) (string= (car (car k)) [remap xref-find-definitions]) (eq (cdr (car k)) (quote go-mode-map)))) ((("<remap> <fill-paragraph>") nil nil) (("<remap> <xref-find-definitions>" . go-mode-map) nil nil)))
(setq personal-keybindings (cl-delete-if (function (lambda (k) (and (consp (car k)) (string= (car (car k)) [remap xref-find-definitions]) (eq (cdr (car k)) (quote go-mode-map))))) personal-keybindings))
(progn (let* ((name [remap xref-find-definitions]) (key (if (vectorp name) name (read-kbd-macro name))) (kdesc (cons (if (stringp name) name (key-description name)) (quote go-mode-map))) (binding (lookup-key (or go-mode-map global-map) key))) (let ((entry (assoc kdesc personal-keybindings)) (details (list nil (if (numberp binding) nil binding)))) (if entry (setcdr entry details) (add-to-list (quote personal-keybindings) (cons kdesc details)))) (define-key (or go-mode-map global-map) key nil)) (setq personal-keybindings (cl-delete-if (function (lambda (k) (and (consp (car k)) (string= (car ...) [remap xref-find-definitions]) (eq (cdr ...) (quote go-mode-map))))) personal-keybindings)))
eval((progn (let* ((name [remap xref-find-definitions]) (key (if (vectorp name) name (read-kbd-macro name))) (kdesc (cons (if (stringp name) name (key-description name)) (quote go-mode-map))) (binding (lookup-key (or go-mode-map global-map) key))) (let ((entry (assoc kdesc personal-keybindings)) (details (list nil (if ... nil binding)))) (if entry (setcdr entry details) (add-to-list (quote personal-keybindings) (cons kdesc details)))) (define-key (or go-mode-map global-map) key nil)) (setq personal-keybindings (cl-delete-if (function (lambda (k) (and (consp ...) (string= ... [remap xref-find-definitions]) (eq ... ...)))) personal-keybindings))) nil)
elisp--eval-last-sexp(t)
#f(compiled-function (eval-last-sexp-arg-internal) "Evaluate sexp before point; print value in the echo area.\nInteractively, with a non `-' prefix argument, print output into\ncurrent buffer.\n\nNormally, this function truncates long output according to the\nvalue of the variables `eval-expression-print-length' and\n`eval-expression-print-level'. With a prefix argument of zero,\nhowever, there is no such truncation.\nInteger values are printed in several formats (decimal, octal,\nand hexadecimal). When the prefix argument is -1 or the value\ndoesn't exceed `eval-expression-print-maximum-character', an\ninteger value is also printed as a character of that codepoint.\n\nIf `eval-expression-debug-on-error' is non-nil, which is the default,\nthis command arranges for all errors to enter the debugger." (interactive "P") #<bytecode 0x1f2d8b>)(t)
ad-Advice-eval-last-sexp(#f(compiled-function (eval-last-sexp-arg-internal) "Evaluate sexp before point; print value in the echo area.\nInteractively, with a non `-' prefix argument, print output into\ncurrent buffer.\n\nNormally, this function truncates long output according to the\nvalue of the variables `eval-expression-print-length' and\n`eval-expression-print-level'. With a prefix argument of zero,\nhowever, there is no such truncation.\nInteger values are printed in several formats (decimal, octal,\nand hexadecimal). When the prefix argument is -1 or the value\ndoesn't exceed `eval-expression-print-maximum-character', an\ninteger value is also printed as a character of that codepoint.\n\nIf `eval-expression-debug-on-error' is non-nil, which is the default,\nthis command arranges for all errors to enter the debugger." (interactive "P") #<bytecode 0x1f2d8b>) t)
apply(ad-Advice-eval-last-sexp #f(compiled-function (eval-last-sexp-arg-internal) "Evaluate sexp before point; print value in the echo area.\nInteractively, with a non `-' prefix argument, print output into\ncurrent buffer.\n\nNormally, this function truncates long output according to the\nvalue of the variables `eval-expression-print-length' and\n`eval-expression-print-level'. With a prefix argument of zero,\nhowever, there is no such truncation.\nInteger values are printed in several formats (decimal, octal,\nand hexadecimal). When the prefix argument is -1 or the value\ndoesn't exceed `eval-expression-print-maximum-character', an\ninteger value is also printed as a character of that codepoint.\n\nIf `eval-expression-debug-on-error' is non-nil, which is the default,\nthis command arranges for all errors to enter the debugger." (interactive "P") #<bytecode 0x1f2d8b>) t)
eval-last-sexp(t)
eval-print-last-sexp(nil)
funcall-interactively(eval-print-last-sexp nil)
call-interactively(eval-print-last-sexp nil nil)
command-execute(eval-print-last-sexp)
For example:
Return errors: