Emacs Build

build emacs 30

on arch linux

  1. 安装依赖

    1
    
    sudo pacman -S cairo giflib gnutls gtk3 harfbuzz jansson libgccjit libjpeg-turbo libotf libpng libsm libtiff libwebp libxcb libxi libxml2 libxpm sqlite tree-sitter xcb-util git libxi xorgproto webkitgtk-6.0 webkit2gtk #icu libavif
  2. 构建准备

    1
    2
    3
    
    cd emacs
    git checkout emacs-30
    ./autogen.sh
  3. configure

    1
    
    ./configure --with-tree-sitter --with-native-compilation=aot --with-mailutils --with-pop --with-xml2 --with-xwidgets --with-x-toolkit=gtk3 # LDFLAGS="-Wl,-rpath,/usr/lib -Wl,-rpath-link,/usr/lib"
  4. get error: webkit2gtk version 太高

Hydra

FAQ

如何通过 esc 键退出 hydra

使用 <escape> 按键配置

1
2
3
4
5
6
7
8
9
(defhydra hydra-root (:color blue)
  "
  _a_: some-action
  _b_: another-action
  "
  ("a" some-action)
  ("b" another-action)
  ("<escape>" nil "quit" :exit t)
  )

Xwidgets

windows + xlaunch

1
2
C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -noprofile -windowstyle hidden -c "$env:DISPLAY = 'localhost:0' ;  ssh -Y gpu 'GTK_THEME=Adwaita:dark WEBKIT_DISABLE_COMPOSITING_MODE=1 nemacs --with-profile clean29 --debug-init'  |out-null"
GDK_BACKEND=x11 WEBKIT_DISABLE_COMPOSITING_MODE=1 ./src/emacs -q

screen Command

翻页

步骤:

  1. 使用 C-a <escape>,进入 copy mode
  2. 使用 <PageUp>/<PageDown> 按键来翻页

plz

使用例子

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
(plz 'post "https://api.moonshot.cn/v1/chat/completions"
  :headers '(("Authorization" . "Bearer $API_KEY")
             ("Content-Type" . "application/json"))
  :body (json-encode `((:model . "moonshot-v1-8k")
                       (:messages .
                                  (((:role . "system")
                                    (:content . "you are a helpful assitant"))
                                   ((:role . "user")
                                    (:content . "why 1 + 1 not equals 2?"))
                                   )))))



;; deepseek
(plz 'post "https://api.deepseek.com/v1/chat/completions"
  :headers '(("Authorization" . "Bearer sk-ff5eed1bfe3e4aa9b749cfc142cc7753")
             ("Content-Type" . "application/json"))
  :body (json-encode `((:model . "deepseek-chat")
                       (:messages .
                                  (((:role . "system")
                                    (:content . "you are a helpful assitant"))
                                   ((:role . "user")
                                    (:content . "What the result of 1 + 1?"))
                                   )))))

json 制作方法

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# * 完整例子
(json-encode `((:model . "moonshot-v1-8k")
                       (:messages .
                                  (((:role . "system")
                                    (:content . "you are a helpful assitant"))
                                   ((:role . "user")
                                    (:content . "why 1 + 1 not equals 2?"))
                                   ))))

# * 单个字段定义
(json-encode `((:role . "system")))
# {"role": "system"}

# * 多个字段定义
(json-encode `((:role . "system") (:id . 3)))
# {"role": "system", "id": 3}


# * 数组定义
(json-encode `(1 2 3))
# [1, 2, 3]

# * 数组字段定义
(json-encode `((:my_array . (1 2 3))))
# {"my_array": [1, 2, 3]}


# * 总结
# ** list --> 数组(python list)
# ** list of cons cell --> 字典