不谈Spacemacs,只谈Centaur Emacs

哎, 忙的搬砖了 还没有细看了 , 停用了prettier好了

我猜问题找到了 , 大概是prettier-js的问题 , issue地址 ,而且我的问题还有点特殊, 就是在我项目根目录下是没有.prettierignore 文件的, 也就是说没有忽略的文件设定然后触发了prettier-js 就清空 , 也没有任何的错误提示 , 文件自动清空 , 我看到vim-pretter这个包也有同样的问题 , 但是vim-prettier 得到了修复 , prettier-js貌似没有人维护了 是一个可用并且过时的插件 , 原谅我lisp功底差 , 不能提供pr

emacs-prettier 是 prettier的官方包,最近没看到有维护。可以参考下vim-prettier是怎么修复的,port下就可以了。你知道vim-prettier的issue地址吗?

我找到了这个issue:Deletes file contents of files ignored by .prettierignore · Issue #92 · prettier/vim-prettier · GitHub 。新看看是怎么回事。

@angelporo 我看了下代码,做了个小patch。因为不知道怎么重现,所以没法在本地测试 。这个修改完全是盲猜,你试试看?

(defun prettier-js ()
  "Format the current buffer according to the prettier tool."
  (interactive)
  (let* ((ext (file-name-extension buffer-file-name t))
         (bufferfile (make-temp-file "prettier" nil ext))
         (outputfile (make-temp-file "prettier" nil ext))
         (errorfile (make-temp-file "prettier" nil ext))
         (errbuf (if prettier-js-show-errors (get-buffer-create "*prettier errors*")))
         (patchbuf (get-buffer-create "*prettier patch*"))
         (coding-system-for-read 'utf-8)
         (coding-system-for-write 'utf-8)
         (width-args
          (cond
           ((equal prettier-js-width-mode 'window)
            (list "--print-width" (number-to-string (window-body-width))))
           ((equal prettier-js-width-mode 'fill)
            (list "--print-width" (number-to-string fill-column)))
           (t
            '()))))
    (unwind-protect
        (save-restriction
          (widen)
          (write-region nil nil bufferfile)
          (if errbuf
              (with-current-buffer errbuf
                (setq buffer-read-only nil)
                (erase-buffer)))
          (with-current-buffer patchbuf
            (erase-buffer))
          (if (zerop (apply 'call-process
                            prettier-js-command bufferfile (list (list :file outputfile) errorfile)
                            nil (append prettier-js-args width-args (list "--stdin" "--stdin-filepath" buffer-file-name))))
              (when (> (file-attribute-size (file-attributes outputfile) 0))
                (call-process-region (point-min) (point-max) "diff" nil patchbuf nil "-n" "--strip-trailing-cr" "-"
                                     outputfile)
                (prettier-js--apply-rcs-patch patchbuf)
                (message "Applied prettier with args `%s'" prettier-js-args)
                (if errbuf (prettier-js--kill-error-buffer errbuf)))
            (message "Could not apply prettier")
            (if errbuf
                (prettier-js--process-errors (buffer-file-name) errorfile errbuf))
            ))
      (kill-buffer patchbuf)
      (delete-file errorfile)
      (delete-file bufferfile)
      (delete-file outputfile))))

刚开始尝试用Centaur Emacs

请问启动时总是卡在网络检查上,mode-line 显示消息如下:

Contacting host : raw.githubusercontent.com:443

我个人平时工作环境基本不联网。请问有办法跳过这个步骤吗?

在联网的环境下载好包,

.emacs.d打包上传到工作环境然后放到对应目录

我已經git clone了,本地已經有.emacs.d 目錄 但是每次啓動還是卡在這裏,需要Ctrl-g才可以。

另外想請教一下,Centaur Emacs使用的包,如ivy等,需要自己去手動安裝嗎? 我git clone完了之後,ivy,rg之類的,似乎還要自己去安裝。否則M-x 調不出相關命令?

你卡着的这个界面就是没安装包/没装完的证明吧.

git clone来的只是配置文件,是不包含包的.

確實如此,剛才重新嘗試了一下,出現了這個問題:

File error: make client process failed, 拒绝连接, :name, raw.githubusercontent.com, :buffer, #, :host, raw.githubusercontent.com, :service, 443, :nowait, nil, :tls-parameters, nil

To ensure normal operation, you should investigate and remove the cause of the error in your initialization file. Start Emacs with the ‘–debug-init’ option to view a complete error backtrace.

不联网怎么安装包呢?除非你在其他地方全部下载下来再copy过来用。

Centaur是支持国内镜像的,可以在custom.el中设置centaur-package-archives为 ustc、tencent等国内源下载包,速度很快。当前前提还是能用网络。

你这个问题估计可以通过将 raw.githubusercontent.com 对应的IP 地址加入/etc/host文件即可解决
(如果是Windows系统,host 文件在C:\Windows\System32\drivers\etc\host。)
至于IP 地址怎么获取,请百度,有很多网站可以解析出来。

可以试试以下几个ip:

199.232.69.194 github.global.ssl.fastly.net
140.82.114.4 github.com
140.82.112.3 github.com
140.82.113.4 github.com
140.82.113.3 github.com
185.199.108.133 raw.githubusercontent.com
185.199.108.133 user-images.githubusercontent.com
185.199.108.133 avatars2.githubusercontent.com
185.199.108.133 avatars1.githubusercontent.com

感谢各位回复。现在已经装好了。

另外请教,

1.自己的配置放在custom-post.el ,这个文件要放在那个目录下?我试着手工创建了一个,也放在了lisp目录下,似乎没什么作用?

2.中文字体改成了更纱等距。目前发现标点符号自动用的是其他字体。比如org-quote文字设成斜体时候,发现标点符号用的是Efont biwidth。正文部分的标点变成了Droid sans fallback。这个是配置有意设计的吗?斜体标点符号目前看起来很难看,如何修正?更纱等距应该是有自己的斜体标点符号的。

3.以前用过一点helm,比较依赖于它接管M-x等命令输入,然后搜索过程中有很多候选可供参考。centaur 里使用ivy 似乎也有这个功能,但是ivy 模式缺省是不是关闭的?可以缺省打开吗?

关于标点符号的字体问题,补充下,和字体大小有关,大多时候是droid,某个大小时会切到efont。总之没有用更纱的标点符号。

这些我就不清楚了,你可以参考下两位大牛的配置:

https://github.com/redguardtoo/emacs.d
https://github.com/seagle0128/.emacs.d

For the personal configurations, you could put to ~/.emacs.d/custom-post.org or ~/.emacs.d/custom-post.el .

项目中打开less 文件包一下错误, 会不会是用lsp配置中使用的lsp服务匹配不上?

LSP :: There are no language servers supporting current mode `less-css-mode' registered with `lsp-mode'.
This issue might be caused by:
1. The language you are trying to use does not have built-in support in `lsp-mode'. You must install the required support manually. Examples of this are `lsp-java' or `lsp-metals'.
2. The language server that you expect to run is not configured to run for major mode `less-css-mode'. You may check that by checking the `:major-modes' that are passed to `lsp-register-client'.
3. `lsp-mode' doesn't have any integration for the language behind `less-css-mode'. Refer to https://emacs-lsp.github.io/lsp-mode/page/languages and https://langserver.org/ .
4. You are over `tramp'. In this case follow https://emacs-lsp.github.io/lsp-mode/page/remote/.
5. You have disabled the `lsp-mode' clients for that file. (Check `lsp-enabled-clients' and `lsp-disabled-clients').

See CSS/LessCSS/SASS/SCSS - LSP Mode - LSP support for Emacs .

你好, 我使用了你的配置, 当前使用emacs版本是emacs 28.0.50, ubuntu18.04, 启动时会出现以一警告, 点它的disable showing没有用: Error (org-roam): Cannot find executable ’sqlite3’. Ensure it is installed and can be found within ‘exec-path’. M-x info for more information at Org-roam > Installation > Post-Installation Tasks. Disable showing Disable logging

不知道该如何让它不提示这个错误

系统中安装sqlite3 client。