用安卓native emacs+termux emacs,抛砖引玉说一下我体验emacs everywhere的个人指南

Tool bar才是Native安卓走向触屏时代的最强mode。下载material icons,转成pbm格式,添加tool bar item,绑定自己的函数即可。可以不需要用unexpected keyboard,配合系统键盘,丝滑使用。

3 个赞

您好,能分享一下配置和pbm吗?

(defun android-toggle-keyboard()
  (interactive)
  (if touch-screen-display-keyboard
      (progn
        (setq touch-screen-display-keyboard nil)
        (tool-bar-add-item
         "keyboard-off" 'android-toggle-keyboard
         'android-toggle-keyboard
         :help "Toggle keyboard")
        (message "Disable virtual keyboard"))
    (setq touch-screen-display-keyboard t)
    (tool-bar-add-item
     "keyboard" 'android-toggle-keyboard
     'android-toggle-keyboard
     :help "Toggle keyboard")
    (message "Enable virtual keyboard")))

(defun android-tool-bar-configs()
  (when (and (fboundp 'tool-bar-mode)
             (string-equal system-type "android"))

    (tool-bar-mode +1)
    (setq! tool-bar-position 'bottom)
    (setq! tool-bar-button-margin 27)
    ;; (modifier-bar-mode +1)

    (setq tool-bar-map '(keymap nil))

    (add-to-list 'image-load-path (expand-file-name "modules/pen" doom-private-dir))


    (android-general-tool-bar 'tool-bar-add-item nil)


  ))

(defun android-general-tool-bar(fun map)
    (mapc (lambda (args)
            (apply fun args))
          `(("keyboard-esc" tool-bar-item-escape keyboard-esc ,map)
            ("file-find-outline" pen-occur file-find-outline ,map)
            ("arrow-down-thick" pen-scroll-up button4 ,map)
            ("arrow-up" tool-bar-item-up arrow-up ,map)
            ("arrow-up-thick" pen-scroll-down button5 ,map)
            ("pen" pen-annotation-mode button6 ,map)
            ("star-plus" pen-add-online-word button7 ,map)
            ("marker" pen-add-highlight button8 ,map)
            ("image-filter-center-focus-strong-outline" focus-mode focus ,map)
            ("menu" pen-goto-toc button10 ,map)

            ("keyboard-tab" tool-bar-item-tab keyboard-tab ,map)
            ("apple-keyboard-command" pen-step-backward apple-keyboard-command ,map)
            ("arrow-left" tool-bar-item-left arrow-left ,map)
            ("arrow-down" tool-bar-item-down arrow-down ,map)
            ("arrow-right" tool-bar-item-right arrow-right ,map)
            ("play" pen-view-note-play play ,map)
            ("syllabary-hiragana" pen-view-current-thing button9 ,map)
            ("history" consult-recent-file history ,map)
            ("file-clock-outline" spacemacs/compleseus-switch-to-buffer file-clock-outline ,map)
            ("keyboard-off" android-toggle-keyboard android-toggle-keyboard ,map)

            ))

  )


(define-key key-translation-map [tool-bar apple-keyboard-command] #'tool-bar-event-apply-control-modifier)
(define-key key-translation-map (kbd "<XF86Back>") [escape])
(define-key key-translation-map [tool-bar keyboard-esc] [escape])
(define-key key-translation-map [tool-bar keyboard-tab]  (kbd "TAB"))
(define-key key-translation-map [tool-bar arrow-up] [up])
(define-key key-translation-map [tool-bar arrow-down] [down])
(define-key key-translation-map [tool-bar arrow-right] [right])
(define-key key-translation-map [tool-bar arrow-left] [left])

最后是这样的

有部分我自己的函数,你换成自己的就好。

pbm太多,不好分享,但是很容易的。

我都是从

这里逐个下载。然后用命令转的

例如

convert keyboard-esc.svg keyboard-esc.pbm

把pbm文件放在指定的image-load-path里面(代码里面有),然后用文件名不含后缀就可以加载了。

android-toggle-keyboard() 不够完美,有待改善。

我个人用音量上下有其他用途,不喜欢用来绑定ctrl和alt,按太多也容易坏。所以我绑定了tool bar的一个item作为ctrl,同时也绑定了安卓的返回键(kbd "<XF86Back>")作为escape。

不过tool-bar的item按住不会连续触发(例如上下左右),这点不知道怎么搞了,有谁知道的话麻烦告诉我一下。

实在非常感谢!!

1 个赞

这个真的很漂亮!

1 个赞