跳至主要内容

博文

目前显示的是标签为“emacs”的博文

Eglot and before/after-save-hook and use-package

In Emacs, when you try to automate some actions during every save action, you will surely get to the before-save-hook and the after-save-hook. Simply adding something like gofmt-before-save to before-save-hook will save you tons of time to do the go-fmt. And then, I meet eglot, and gopls will also save me tons of time doing googling and api documentation navigation. But eglot-ensure is not very friendly to the good old ways of how after-save-hooks were designed to work. It makes the before/after-save-hook a buffer local variable and it does not inherit the variable's global value. So, to make before/after-save-hook work again, experts start to adding hooks to major mode specific hooks like this: emacs.md - Go (opensource.google) """ ;; Optional: install eglot-format-buffer as a save hook. ;; The depth of -10 places this before eglot's willSave notification, ;; so that that notification reports the actual contents that will be saved. (defu...

Windows 10 下键盘设置技巧

CJK Emacs 用户 Windows 10键盘设置  其实并不是特别多Emacs用户有这么奇怪的要求: 要有CJK输入法 要有Emacs来满足输入快感 要CJK输入法的激活方式与Emacs热键不互相冲突  要右边的 Alt 按键和左侧的 Alt 一样可以在Emacs中用作 Meta 键  下面是我正在 Windows 10 系统使用的配置:  要求1,不需要特殊配置,windows 10 自带了各种地区的输入法,并且对于中文用户还很贴心的默认激活……  要求2,只要安装了 Emacs 就好。  要求3,为 Windows 10 添加一个“美式键盘”。如此一来,只要切换到这个英语键盘,Ctrl-Space 热键就可以直接被 Emacs 接收到,而不是被系统截获用作输入法开关了。同时,Win-Space 组合会成为键盘级别的切换。  要求4,为 Windows 10 添加 “美式键盘”的时候,一定选择不带任何修饰的 “美式键盘”。切记不要选择 “国际”版本,那是一个把右侧 Alt 键转换成 AltGr 的特殊设置(只有输入特殊的欧洲字符时才用的到,至少我是用不到的)。  还有一个曾经从 WinXP 时代流传下来的注册表设置: right alt -> left alt ------------------------------------ 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,38,00,38,e0,\ 00,00,00,00   ------------------------------------

XEmacs 21.5 beta 35 "kohlrabi" has been released.

If you are an old XEmacs user, you may feel happy to see this from https://www.xemacs.org/.    After ten years, XEmacs released a new version 21.5. So there's still many people cares about XEmacs. The XEmacs' source repo have been moved from altassian Bitbucket to https://heptapod.net/. As Bitbucket have been dropped Mercurial support many years ago.

Fido-mode

Today, I've just discovered the Fido mode, a modified `icomplete` minor mode. `icomplete` used to be one of my favorite mode days back to my XEmacs days. Pros: It is way fast. It is much more smart in terms of find the complete candidate that you want mostly.  Cons: It does not integrate well enough with tramp yet.    `fido-mode` is a core package of Emacs 27+, and there's a vertical version available after Emacs 28+ named `fido-vertical-mode`. UPDATE: I am back with ido now

Read the function description of dired-omit-mode

If you don't know how to enable `dired-omit-mode` for every dired buffer, like me. Read the `dired-omit-mode` function description with `C-h f dired-omit-mode`, where it said: To enable omitting in every Dired buffer, you can put this in your init file:   (add-hook 'dired-mode-hook (lambda () (dired-omit-mode)))

Use HTML

 Okay, I've finally found the HTML mode in the blog editor today. Alas. I'd paste all my HTML blog backups in if I've found it before the re-construction of my blog. Anyway, at least I am able to make use of Emacs org-mode's HTML exports for blog publishing. It's much better than writing by hand with the web based blog editor, already. A good beginning. Good night everyone.

My simplified Emacs setup

‎ Table of Contents 1. I have Emacs 28 installed on Windows. 1.1. With following list from GNU and MELPA archive: 1.2. and a list of customized key maps: 1.3. And default modes: 1.4. And Usage Package Settings: 1. I have Emacs 28 installed on Windows. 1.1. With following list from GNU and MELPA archive: (custom-set-variables '(package-selected-packages '(nano-agenda nano-modeline nano-theme use-package languagetool eglot cnfonts company-box company-tabnine multiple-cursors beacon))) 1.2. and a list of customized key maps: (global-set-key (kbd "C-x C-b") 'ibuffer) (global-set-key (kbd "C-S-c C-S-c") 'mc/edit-lines) (global-set-key (kbd "C->") 'mc/mark-next-like-this) (global-set-key (kbd "C-<") 'mc/mark-previous-like-this) (global-set-key (kbd "C-c C-<") 'mc/mark-all-like-this) 1.3. And default modes: (beacon-mode 1) (cnfonts-mode 1) (nan...

find pylance directory

So your pylance upgrade very often? init snap here to rescue. ( defun find-pylance () ( let* ((vscode-extensions-directory (expand-file-name ".vscode/extensions" (getenv "UserProfile" ))) (pylance-directory (car (seq-filter ( lambda (elt) (string-match-p ".*pylance.*" elt)) (directory-files vscode-extensions-directory))))) (concat (file-name-as-directory vscode-extensions-directory) (file-name-as-directory pylance-directory) "dist/server.bundle.js" ))) (add-to-list 'eglot-server-programs `(python-mode . ( "node" ,(find-pylance) "--stdio" ))) (add-hook 'python-mode-hook 'eglot-ensure)  

Eglot mode with MS pylance language server

Step by Step how-to follows Install Pylance by any means. I did it by install it from VS Code plugin manager. (You know, language server is the VS Code thing). Install nodejs by any means. I did it by doing a choco install nodejs . In emacs M-x package-list-packages search for eglot-mode mark it to be installed with key i , then hit key x to install. Configure Emacs to initialize package-system and elgot by adding the following elisp snippets to init.el . ( require ' package ) (package-initialize) ( require ' eglot ) ;; VSCode install extentions in ~/.vscode or %UserProfile%\.vscode directory. e.g. ;; C:\\Users\\ekaifan\\.vscode\\extensions\\ms-python.vscode-pylance-2020.8.2\\server\\server.bundle.js (add-to-list 'eglot-server-programs '(python-mode . ( "node" "PATH_TO_YOUR_PYLANCE_SERVER_DOT_BUNDLE_DOT_JS" "--stdio" ))) (add-hook 'python-mode-hook 'eglot-ensure) Customize your eglot behavior by M-x customize-group...

org2jeklly is changing... excerpt: Some change breaks my current workflow, and the workaround

publish failure in org2jeklly 0.25 Some time ago, I started using org2jeklly to publish my blogs. All went well until someday I did a package upgrade for all my emacs packages… My publishing start to fail, there's no markdown file produced after I run `M-x org2jeklly-publish`… There's `org-export-process exited abnorml` message in Message buffer. org-export-process exited abnormally issue Several hours of debug show that the "org-export-process" related issue was caused by there's no correct org asynchronous export setting. To fix it, add the following snippet to .emacs: (custom-set-variables '(org-export-async-init-file "~/.emacs.d/org-async-init.el" )) And create a "~/.emacs.d/org-async-init.el" with following contents: ( require ' package ) ( setq package-enable-at-startup nil) (package-initialize) ( require ' org ) ( require ' ox ) ( setq org-export-async-debug t) no markdown genera...

Emacs 26.2 windows Hunspell setup

 Hunspell failed with default setup With my shining new emacs26.2 setup, I am happy until trying to `M-$’ on a word. I got following error message, it used to be work by just set ispell program to hunspell. Starting new Ispell process hunspell with default dictionary... split-string: Wrong type argument: stringp, nil After some check in my customization setting. nothing found. install a copy of hunspell dictionary At first I think it was caused by no hunspell dictionary. I downloaded en US and en CA hunspell dictionary from wordlist.sf.net project. After put the .aff and .dic files into C:directory I’ve also made a symbolic link from en US ones by running the `mklink’ tool: mklink default.aff en_US.aff mklink default.dic en_US.dic Err… hunspell does not work, still. Time to read code Dig into ispell.el I suprisingly find there’re lots of hunspell specific logic. Originally I was thinking hunspell support involves no elisp work. Acturally ispell did many work to de...

Fira code fonts mess-up in Intellij IDEA

The beautiful, open source, with ligatures, font Fira Code Some month ago I see someone talking about the best fonts and themes for their Intellij IDEA setup. One of the setups is really good, it was my first time to know that symbols such as `<=’ or `->’ can be display as beautiful arrows at runtime by supported software and a supported font. The font that mentioned was Fira Code Install FiraCode and fonts mess up in various programs I do like the beautiful ligatures. And, `choco search fira’ shows that the font can be easily installed by Chocolatey, Great!!! Anyway, things are not as good as I expected. Fira code fonts seems not work well in my Windows 7 ClearType environment. It shows up hideous in my Emacs buffer, even worse, it will mess up totally in J2SE Swing program if subpixel hint is turned on. Recovery method I tried several recovery methods, they are either no help or fail back to old situation after one or two cycles of Windows reboot. Remove/reinsta...