WANGZ's blog / Tags

windows 下的开发环境搭建(零)

1 键位设置

1.1 系统快捷键位

1.1.1 将 caps 键位映射成 ctrl

Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Keyboard Layout]
"Scancode Map"=hex:00,00,00,00,00,00,00,00,02,00,00,00,1d,00,3a,00,00,00,00,00

1.1.2 禁用 win+l

Windows Registry Editor Version 5.00

[HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Policies\System]
"DisableLockWorkstation"=dword:00000001

1.2 autoHotKey

1.2.1 解决 ctrl-space 问题

LINK: https://www.zhihu.com/question/22288432/answer/502086049
#IfWinActive ahk_class Emacs   ; if in emacs
^Space::^+2 ;(Ctrl+Shift + 2)
#IfWinActive                   ; end if in emacs

2 终端

2.1 install windows terminal

2.2 install msys2

2.2.2 将 msys2 塞入 windows terminal

LINK: https://www.msys2.org/docs/terminals/
// This makes MINGW64 the default shell
"defaultProfile": "{17da3cac-b318-431e-8a3e-7fcdefe6d114}",
"profiles": {
    "list":
    [
        // ...
        {
            "guid": "{17da3cac-b318-431e-8a3e-7fcdefe6d114}",
            "name": "MINGW64 / MSYS2",
            "commandline": "C:/msys64/msys2_shell.cmd -defterm -here -no-start -mingw64",
            "startingDirectory": "C:/msys64/home/%USERNAME%",
            "icon": "C:/msys64/mingw64.ico",
            "fontFace": "Lucida Console",
            "fontSize": 9
        },
        {
            "guid": "{2d51fdc4-a03b-4efe-81bc-722b7f6f3820}",
            "name": "MINGW32 / MSYS2",
            "commandline": "C:/msys64/msys2_shell.cmd -defterm -here -no-start -mingw32",
            "startingDirectory": "C:/msys64/home/%USERNAME%",
            "icon": "C:/msys64/mingw32.ico",
            "fontFace": "Lucida Console",
            "fontSize": 9
        },
        {
            "guid": "{71160544-14d8-4194-af25-d05feeac7233}",
            "name": "MSYS / MSYS2",
            "commandline": "C:/msys64/msys2_shell.cmd -defterm -here -no-start -msys",
            "startingDirectory": "C:/msys64/home/%USERNAME%",
            "icon": "C:/msys64/msys2.ico",
            "fontFace": "Lucida Console",
            "fontSize": 9
        },
        // ...
    ]
}

2.2.3 设置清华源

sed -i '1 i Server = https://mirrors.tuna.tsinghua.edu.cn/msys2/mingw/i686' /etc/pacman.d/mirrorlist.mingw32
sed -i '1 i Server = https://mirrors.tuna.tsinghua.edu.cn/msys2/mingw/x86_64' /etc/pacman.d/mirrorlist.mingw64
sed -i '1 i Server = https://mirrors.tuna.tsinghua.edu.cn/msys2/msys/$arch' /etc/pacman.d/mirrorlist.msys

2.2.4 更新

pacman -Syu

3 emacs

3.1 安装 gccemacs

LINK: https://emacs.stackexchange.com/questions/61775/is-there-a-gccemacs-native-comp-build-for-ms-windows

3.1.1 下载源

git clone -b feature/native-comp --depth=1 https://gitee.com/mirrors/emacs.git

3.1.2 安装 MINGW64 依赖

$ pacman -S --needed base-devel \
  mingw-w64-x86_64-toolchain \
  mingw-w64-x86_64-xpm-nox \
  mingw-w64-x86_64-libtiff \
  mingw-w64-x86_64-giflib \
  mingw-w64-x86_64-libpng \
  mingw-w64-x86_64-libjpeg-turbo \
  mingw-w64-x86_64-librsvg \
  mingw-w64-x86_64-lcms2 \
  mingw-w64-x86_64-jansson \
  mingw-w64-x86_64-libxml2 \
  mingw-w64-x86_64-gnutls \
  mingw-w64-x86_64-zlib \
  mingw-w64-x86_64-harfbuzz

3.1.3 编译

./autogen.sh
./configure --without-dbus --without-pop --with-native-compilation
make -j$(nproc) # or make NATIVE_FULL_AOT=1 -j$(nproc) // longer
make install

3.1.4 启动

  1. 创建 emacsclientw.exe 的快捷方式

    值为

    C:\msys64\mingw64\bin\emacsclientw.exe -n -c -a ""
    
  2. init.el 中添加环境变量
    LINK: https://emacs-china.org/t/windows-msys2-native-comp/16269
    
    (let ((msys2root "C:\\msys64"))
      (setenv "PATH" (concat
                      msys2root "mingw64\\bin" ";"
                      msys2root "usr\\bin" ";"
                      (getenv "PATH")))
      ;;without this the new added $PATH value won't be inherite by exec-path
      (setq exec-path (split-string (getenv "PATH") path-separator)))
    

Other posts
Powered by Org-mode and a fork of org-static-blog