什么情况下不应该使用“kbd”?


#1

我一般表示一个键位都用(kbd "<key>")的形式("<key>"指具体的键位)。

而我看到很多人都不这么干,那么什么情况下不该使用kbd

谢谢


#2

Why not?

不如全部都用kbd。天下大同岂不美哉


#3

因为我是一个没有主见的人,尤其在Emacs配置上


#4

哦,非要说的话,比起直接写键绑定的字面量,用kbd会慢点


#5

我都用kbd,感觉很一致清爽,其他方式那种反斜杠看的很碍眼。

举个例子就是,python 2的print statement和python 3的print,我倾向后者


#6

我现在是一般的键用kbd,需要绑定功能键和特殊键(比如F1~F12,Return之类的)就直接写


#7

用kbd挺好的啊。下面是我自己的初始化文件的节选,所有直接用Vector定义的都是才开始玩Emacs的时候写下的,所有用kbd都是玩了一段时间之后写下的。

(global-set-key [f5] 'redraw-display)
(global-set-key [f6] 'untabify)
(global-set-key [S-f6] 'tabify)
(global-set-key [f7] 'delete-trailing-whitespace)
(global-set-key [f8] 'whitespace-mode)
(global-set-key [f9] 'hl-line-mode)
(global-set-key [f12] 'speedbar-get-focus)
(global-set-key [?\M-s ?f] 'flush-lines)
(global-set-key [?\M-s ?c] 'count-matches)
(global-set-key [?\M-s ?\M-s] 'rgrep)
(global-set-key [?\M-s ?s] 'find-dired)
(global-set-key [?\M-s ?\M-f] 'find-file-at-point)
(global-set-key [?\C-c ?a] 'org-agenda)
(global-set-key [?\M-s ?l] 'sort-lines)
(global-set-key (kbd "M-s d") 'dictionary-lookup-definition)
(global-set-key (kbd "M-s M-d") 'dictionary-lookup-all-definitions)
(setq scroll-horizontal-step 3)
(require 'cl)
(defun scroll-horizontal (scroll-func)
  (lexical-let ((scroll-func scroll-func))
    (lambda ()
      (interactive)
      (funcall scroll-func scroll-horizontal-step))))
(global-set-key (kbd "<S-mouse-4>") (scroll-horizontal 'scroll-right))
(global-set-key (kbd "<S-mouse-5>") (scroll-horizontal 'scroll-left))
(global-set-key (kbd "<mouse-6>") (scroll-horizontal 'scroll-right))
(global-set-key (kbd "<mouse-7>") (scroll-horizontal 'scroll-left))
;; (global-set-key [remap scroll-right] (scroll-horizontal 'scroll-right))
;; (global-set-key [remap scroll-left] (scroll-horizontal 'scroll-left))
(global-set-key (kbd "C-x C-b") (lambda () (interactive) (ibuffer t)))
;; (global-set-key (kbd "<mouse-2>") 'clipboard-yank)
(global-set-key (kbd "<Scroll_Lock>") 'scroll-lock-mode)
(global-set-key (kbd "C-x C-y") 'scroll-lock-mode)
(global-set-key (kbd "C-x j") 'dired-jump)
(global-set-key (kbd "C-x 4 j") 'dired-jump-other-window)
(global-set-key (kbd "C-x M-f") 'recentf-open-files)
;; (global-set-key (kbd "<switch-frame>") 'ignore)
(global-unset-key (kbd "C-z"))
(global-unset-key (kbd "C-x C-z"))

(defun pp-eval-print-last-sexp ()
  (interactive)
  (terpri (current-buffer))
  (pp-eval-last-sexp t))

(global-set-key [remap eval-print-last-sexp] 'pp-eval-print-last-sexp)
(global-set-key [remap read-only-mode] 'view-mode)
(global-set-key (kbd "C-x v -") 'vc-ediff)