你最近移除了哪些插件和功能

我也用 tempel 代替了 yasnippet 。 用下来 tempel 比 yasnippet 好魔改多了,两三个函数就能实现比 auto-yasnippet 强得多的功能,新建和自动展开 snippets 也比 yasnippet 快,而且最近糊了个正则匹配展开,把之前用 yasnippet 时的痛点几乎都解决了。

现在唯一不舒服的地方就是不能彻底删掉 yasnippet ,有很多包依赖它。

正则匹配的 demo:

比如说有下面的 snippet :

("\\([0-9]\\)\\([0-9]\\)t" (org-table-create (format "%sx%s" \1 \2)))

Peek 2023-10-06 15-50

7 个赞

这个没必要用到 yasnippet 吧。自己写个函数绑定到 TAB 键就可以了:

(defun indent-for-tab-command@around (&rest args)
  "Advice around `indent-for-tab-command' or `org-cycle'."
  (interactive "P")
  (cond ((looking-back "\\([0-9]\\)\\([0-9]\\)t")
         (let ((size (format "%sx%s" (match-string 1) (match-string 2))))
           (delete-extract-rectangle (match-beginning 0) (match-end 0))
           (org-table-create size)))
        (t (apply args))))
2 个赞

可能是我的表述有点不清楚,我指的是 UltiSnips 那种通过正则匹配 trigger words 来展开 snippets 的方式,yasnippet 目前是不支持的,详见 Adding support for regex as keys when expanding snippets

专门写个函数太浪费了,这种应用场景还是挺多的,比如 NxM 的表格或矩阵。如果插件本身支持的话灵活性能提升很多。

2 个赞

我也想过替换掉yasnippet,但是lsp客户端还得用它,只能保留着。

我前段时间又换回 yasnippet 了,因为 eglot 依赖它进行 snippet 展开。暂时放弃用 tempel了。

1 个赞

eglot tempel可以在eglot上使用tempel来展开

这个包以前试过,展开时会出错,后来就没用了。

现在用 yasnippet 挺好,懒得换回去了。

1 个赞

我则是写了个函数,如果前缀是 tempel 的前缀的话就展开 tempel,如果在 tempel 补全过程中就执行 tempel-complete,否则 completion-at-point,实现了绑定到一个快捷键上。虽然没有对任何前缀都支持,但对我个人 ( < 前缀)够用了。

(keymap-global-set "C-<return>" #'mk/completion-at-point-with-tempel)

(defun mk/completion-at-point-with-tempel ()
  "`Completion-at-point' function with tempel support.
When tempel-trigger-prefix is before the point, then use temple, else `completion-at-point'."
  (interactive)
  (if tempel--active
    (call-interactively 'tempel-next)
    (if (and tempel-trigger-prefix
          (length> tempel-trigger-prefix 0)
          ;; TODO
          (looking-back (rx-to-string `(seq ,tempel-trigger-prefix (* (not space)))) nil))
      (call-interactively 'tempel-complete)
      (completion-at-point))))

(use-package tempel
  :custom
  (tempel-path (expand-file-name "templates/*.eld" user-emacs-directory))
  (tempel-trigger-prefix "<")
  :init
  (add-hook 'prog-mode-hook #'tempel-abbrev-mode)
  (add-hook 'text-mode-hook #'tempel-abbrev-mode))

Eglot 作者开始重写 Yasnippet了

8 个赞

目前一直用 tempel,还没遇到什么问题,等 yas 重写完了和 tempel 对比一下 :yum:

org-sticky-mode,将工作记录挪到logseq里去了,emacs专注个人的笔记

tempel有什么优势吗?目前没有找到特别好的snippets

最近移除了 straigh.el ,功能和作者的文档一样“沉重”。

同移除了 straight.el,改用了懒猫大佬推崇的 submodule。

整个工程还是耗时不少,但是真的很爽!而且 submodule 一样能实现「声明式」的 package 安装。

现在真不明白 Emacs 那些包管理器在折腾什么 :rofl:

1 个赞

用submodule管理的话,在不同电脑上需要custom的地方是怎么处理的呢,custom的部分也会用到一些包,比如我工作电脑用到了jq-format、jq-mode,但是我自己电脑就没有这些需求,这些包我并不想纳入git管理范围之内

不想纳入 git 管理范围的话直接克隆到其他目录,配置写到 private 文件比如 custom.el 就可以了😂不用想得太复杂

2 个赞

都纳入 git 管理, 但是你配置里面可以根据环境不同, 选择加载不同的模块即可。

2 个赞

包管理器作为主流方式贡献肯定是正面的,如此评价有失公允,还是多点respect。

7 个赞

如果希望达到正则 snippet 的效果,是不是需要 hack tempel 呀,我直接加入这个 sinnpet 会报

File mode specification error: (wrong-type-argument symbolp \([0-9]\)\([0-9]\)t)

删除了 fullframe 和 ibuffer,后者是因为 C-x b 感觉已经够用了,前者和后者本来是搭配使用。另外 magit 也有到了 fullframe,但是完全可以用函数来替代。

(defun magit-fullscreen (orig-fun &rest args)
  (window-configuration-to-register :magit-fullscreen)
  (apply orig-fun args)
  (delete-other-windows))

(defun magit-restore-screen (&rest args)
  (jump-to-register :magit-fullscreen))

(advice-add 'magit-status :around #'magit-fullscreen)
(advice-add 'magit-mode-quit-window :after #'magit-restore-screen)
1 个赞