manateelazycat / awesome-tab

Emacs package to provide out-of-the-box configuration to use tabs.
383 stars 38 forks source link

mac iTerm2下无法切换tab #81

Closed shuxiao9058 closed 4 years ago

shuxiao9058 commented 4 years ago
  (dotimes (tabnum 10)
    (global-set-key
     (kbd (concat "M-" (number-to-string tabnum)))
     'awesome-tab-select-visible-tab))

但是切换的时候会报错,已经将“option”按键设置为“+ESC”了

progn: Buffer is read-only: #<buffer *Backtrace*>
awesome-tab-select-visible-tab: Wrong type argument: stringp, nil

如下所示为describle-key的描述信息。

M-1 runs the command awesome-tab-select-visible-tab (found in
global-map), which is an interactive compiled Lisp function in
‘awesome-tab.el’.

It is bound to ESC 0..9.

(awesome-tab-select-visible-tab)

Bind this function with number keystroke, such as s-1, s-2, s-3 ... etc.

This function automatically recognizes the number at the end of the keystroke
and switches to the tab of the corresponding index.

Note that this function switches to the visible range,
not the actual logical index position of the current group.
manateelazycat commented 4 years ago

先用 M-x toggle-debug-on-error 打开调试选项,再复现后,把 backtrace 的内容粘贴一下。

感谢反馈!

shuxiao9058 commented 4 years ago

先用 M-x toggle-debug-on-error 打开调试选项,再复现后,把 backtrace 的内容粘贴一下。

感谢反馈!

Debugger entered--Lisp error: (wrong-type-argument stringp nil)
  string-to-number(nil)
  awesome-tab-select-visible-tab()
  funcall-interactively(awesome-tab-select-visible-tab)
  call-interactively(awesome-tab-select-visible-tab nil nil)
  command-execute(awesome-tab-select-visible-tab)
manateelazycat commented 4 years ago
(defun awesome-tab-select-visible-tab ()
  "Bind this function with number keystroke, such as s-1, s-2, s-3 ... etc.

This function automatically recognizes the number at the end of the keystroke
and switches to the tab of the corresponding index.

Note that this function switches to the visible range,
not the actual logical index position of the current group."
  (interactive)
  (let* ((event last-command-event)
         (key (make-vector 1 event))
         (key-desc (key-description key)))
    (message "%s" key-desc)
    (awesome-tab-select-visible-nth-tab
     (string-to-number (nth 1 (split-string key-desc "-"))))))

你把上面的代码执行一下,然后再按键,看看 minibuffer 显示 key-desc 是啥?

shuxiao9058 commented 4 years ago

M-1的时候key-desc是1,但是还是报错。

shuxiao9058 commented 4 years ago

如下所示是正常的


  (defun awesome-tab-select-visible-tab ()
    "Bind this function with number keystroke, such as s-1, s-2, s-3 ... etc.

This function automatically recognizes the number at the end of the keystroke
and switches to the tab of the corresponding index.

Note that this function switches to the visible range,
not the actual logical index position of the current group."
    (interactive)
    (let* ((event last-command-event)
           (key (make-vector 1 event))
           (key-desc (key-description key)))

      (awesome-tab-select-visible-nth-tab
       (string-to-number (or (nth 1 (split-string key-desc "-")) key-desc)))))
manateelazycat commented 4 years ago

最新版应该已经修复了。

shuxiao9058 commented 4 years ago

现在没问题了,多谢 ~