Skip to content

LuciusChen/.emacs.d

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

.emacs.d

assets/screenshot_1.png

字体

主要使用 JetBrains Mono,vterm-mode、prog-mode 和 org-mode 下使用 PragmataPro;中文字体使用霞鹜文楷,选择 Jigmo fonts 全覆盖 CJK 字符集作为 fallback 字体。

特殊字体

需要安装 Symbola 字体,安装 Symbola 后 Emoji 需要添加额外的设置,才可以用 Mac 内置的 Emoji,参考 Emacs:Set Font in Init File。Emoji 的一些在 Unicode 中分布比较零散,比较好的方式是先设置 Emoji 再设置 CJK。(由于 Symbola 和 nerd-icons 所需字体有一些重复,所以需要先安装 Symbola 再安装 nerd-icons 所需字体。)

包管理工具

特点就是简单可定制,其中需要注意的是 :bind-into 有一些问题,详见 ~pkal/setup: Deprecate passing a map to :bind-into - sourcehut git,要避免这个问题其实可以采用下面的写法。

(:with-map xxx-map (:bind "C-c x t" xxxx))

Themes

LuciusChen/modus-themes forked from protesilaos/modus-themes,颜色方案参考了 tailwind-colors

透明以及毛玻璃效果可以参考下面两个 patch

例如添加透明 patch,需要在 /opt/homebrew/Library/Taps/d12frosted/homebrew-emacs-plus/Formula/[email protected] 中添加 local_patch "ns-alpha-background", sha: "eae9abd14c2d00315806116e0eaba09510e98738b420d6e40a9d7d97d9437b81"= 并把 ns-alpha-background.patch 文件放在 =/opt/homebrew/Library/Taps/d12frosted/homebrew-emacs-plus/patches/emacs-30 下。

.authinfo

machine api.openai.com login apikey password ****
machine matrix.org login @lucius_chen:matrix.org  password ****
machine api.github.com login LuciusChen^forge password ****

Matrix 的 key 是在 All Settings -> Help & About 当中的 Access Token 处获取。

Reader

assets/org.png 用过一段时间的 Readwise Reader,选择其的原因在于可以配合沉浸式翻译,达到快速阅读英文书籍及文章的目的。但是目前在 Emacs 当中也可以通过 gpt 的应用达到相同的目的。

通过 Elilif/emacs-immersive-translate 进行翻译。其中 OpenAI 需要绑定支付方式后才可以使用,可以使用我的 WildCard 邀请链接注册充值,享受88折优惠。

阅读书籍 ePub 用 nov.el,阅读 PDF 用 vedang/pdf-tools;RSS 订阅用 skeeto/elfeedkarthink/elfeed-tube,其中后者可以拉取字幕,配合沉浸式翻译,可以快速阅读内容,关键处再用 mpv 打开视频,点击字幕跳转到关键处。Elfeed 中也可以方便的创建 org 笔记,根据不同的类型定制模板(lucius/menu-dwim–org-capture-elfeed-show)。

ChatGPT 的应用可以通过 karthink/gptel 在 Emacs 当中使用。

agenda 的使用参考卡片笔记以及 PARA 形成了一套自己的方法,入门可以参考 Get Things Done with Emacs,另外 org-agenda 的使用,如果需要用到动态加载文件进 agenda 可以参考 Dynamic org-agenda with org-roam

org-latex-preview

使用 tec/org-mode 版本的 org 进行实时预览,配置可以参考 =org-latex-preview=: Set up and troubleshooting

如果用 Homebrew 安装的 texlive,dvisvgm 包含在 texlive 当中,从 /Library/TeX/texbin/ 复制到 /opt/homebrew/bin/ 就可以了。

对于有 mathjax 不支持显示的文章可以通过头部添加 #+OPTIONS: tex:dvisvgm 来将内容都以图片的形式导出嵌入文章中。若是出现图片偏离文本基线的问题,很可能是 Hugo 主题中定义了 img 标签的 margin 属性,比如正在用的 reorx/hugo-PaperModX 主题中就定义了,覆盖就好。

img.org-latex.org-latex-inline.medium-zoom-image {
    margin: 0.25em;
}

但是上述这种对于一些 MathJax 支持的公式也会以图片的形式导出,算不上最好的方式。完美的方式通过 org-babel 导出 svg,其他的继续用 MathJax 渲染。

2024-03-08: tec/org-mode 版本中 org-latex-compile 改为异步生成 PDF,所以在 Inkscape 转换 PDF 为 SVG 时,PDF 还未生成,导致报错。相关参考如下。

\begin{algorithm}[H]
  \renewcommand{\thealgocf}{} \SetKwProg{FnOn}{on}{ do}{end}
  \caption{Lamport clocks algorithm}
  \FnOn{\textsf{\upshape initialisation}} {$t := 0$ \tcp*{each node
      has its own local variable t}} \FnOn{\textsf{\upshape any event
      occurring at the local node}} {$t := t + 1$}
  \FnOn{\textsf{\upshape request to send message $m$}} {$t := t + 1$\;
    \textsf{\upshape send $(t, m)$ via the underlying network link}}
  \FnOn{\textsf{\upshape receiving $(t', m)$ via the underlying
      network link}} {$t := \max(t, t') + 1$\; \textsf{\upshape
      deliver $m$ to the application}}
\end{algorithm}

Telega

针对 UI 做了一些修改 GitHub - LuciusChen/telega.el: GNU Emacs telegram client (unofficial)

  • +修改了 msg-heading 的背景,只保留用户名所在行的背景+​(移到👆🏻上面 forkd 的主题中去了),只保留用户名长度的背景。
  • 修改了按钮的样式 (移到👆🏻上面 forkd 的主题中去了)
  • 回复样式修改字体颜色为绿色且 =| In reply to:= 变为 | ➦: (已在 commit 93fedce 实现)
  • 回复行中用户名过长,则省略以显示更多的「被回复」内容。
  • 转发样式修改字体颜色为黄色且 ~| Forward from:~ 变为 | ➥: (已在 commit 93fedce 实现)
  • 去除关于 bot 命令补全的断言。原本只能在与 bot 的私聊中使用 / 进行补全,修改后可以在群聊中使用 / 进行补全(作者原话指出这样会 controversial and even dangerous)。
  • 修改 Specific Quote 以及正文中包含的 Quote 的样式,用 标识,并在每行前插入空格对齐。
  • 修改 reactions 图标为字符而非 emoji 以及其颜色
  • 在 header 查看数量、转发数量和回复数量的标识和数字之间添加空格。
  • 去除 telega-root 顶部空行
  • 修改 code blocks 样式,替换 codeblock 符号为 nerd-icons 对应语言的 icons,没有则显示 codeblock 符号。codeblock 头部增加背景填充整行,最后一行代码也填充整行。
  • 重新排布了 edited-date、消息查看数量、回复数量、转发数量的位置,兼容 telega-ins--message-date-and-statusnon-nil 的情况。并且对于消息同一个人发的尽量合并到一个 header 下。
  • 由于上一条的改动,多条消息都会在一个 header 下,因此在 no-header 的消息上方增加了 25% 行高的行距。
  • 以上 nerd-icons 修改在终端同样有效
  • 去掉 notification 的 dbus 依赖,改为数量显示在 tab-bar 当中,同时被查看过的会从 telega-notifications-history 中删除。

assets/telega-collection.png

assets/telega_reply_username.png

assets/SCR-20240125-oqao.png

assets/SCR-20240122-ppqy.png

Building TDLib

brew install tdlib 的版本过低,需要自行编译,参考 TDLib build instructions 。这个之后需要 M-x telega-server-build 重新加载 telega-server。

xcode-select --install
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
brew install gperf cmake openssl
git clone https://github.com/tdlib/td.git
cd td
rm -rf build
mkdir build
cd build
cmake -DCMAKE_BUILD_TYPE=Release -DOPENSSL_ROOT_DIR=/usr/local/opt/openssl/ -DCMAKE_INSTALL_PREFIX:PATH=/usr/local ..
cmake --build . --target install
cd ..
cd ..
ls -l /usr/local

如果报错 ~”user-error: TDLib is not installed into “/usr/local”. Set ‘telega-server-libs-prefix’ to the TDLib installion path”​,则可以通过 ~M-: (setq telega-server-libs-prefix “/path/to/tdlib/install/path”) RET 然后 M-x telega-server-build RET 重新构建。

Animated Stickers

git clone https://github.com/zevlg/tgs2png.git
git submodule init
git submodule update --init --recursive
mkdir build
cd build
cmake ..
make
copy tgs2png somewhere into $PATH

可以 C-h v 查看 exec-path 变量的值,将 tsg2png 复制到对应的路径即可。另外针对 video stickers 需要 brew install ffmpeg 才可以播放。

contrib 中的插件。

telega-url-shorten

原先插件的做法是针对每个网站的 URL 进行适配,并且配上与之相应的 icons,并不能完全满足所有 URL 缩短的目的,所以这里用 ^\\(https?://\\)\\(.\\{55\\}\\).*?$ 正则处理所有的 URL,超过一定长度后省略。

telega-bridge-bot

可以方便的同步 Matrix 那边的头像到 Telega 这边,对于「图象记忆者」来说,根据「头像 + username」记忆人远比单独的 username 记忆要牢固快速的多。

assets/telega-bridge-bot.png

telega-mnz

高亮消息中的代码块

Frequent Shortcuts

C-u C-c C-k取消回复和附带的文件,不保留所输入文字(用得最多)
C-c C-k取消回复和附带的文件,但保留所输入文字(不用 只用上面↑)
C-c C-a粘贴一切(常用,可覆盖以下两个场景:)
C-c C-v贴 clipboard 里的东西(常用,比如刚截的图在剪贴板里)
C-c C-f粘媒体文件(偶用)
M-g m下一个提醒(常用)
M-g r直接跳到最新消息(常用)
M-g !跳转到最新的 reactions
M-g ^跳转到最新的 Pin 消息
M-g x编辑消息发送后,回到被编辑消息位置

聊天界面

r回复该消息
C-u r在另一个聊天内回复该消息
e编辑该消息
d删除该消息
fforward
ssave
ccopy

Tricks

C-x C-e 可以执行 elisp 或者在 Scratch 中开启 lisp-interaction-mode 后,在需要执行的函数最后 C-j 执行。

Working with Frame

CommandWhat it does
C-x 5 0Close current frame
C-x 5 1Close all frames except the current one
C-x 5 2Create a new frame

Working with windows

CommandWhat it does
C-x 0Close current window
C-x 1Close all windows except the current one
C-x 2Split current window in two vertically
C-x 3Split current window in two horizontally
C-x oSwitch to other window

Rollback emacs-plus with Homebrew

brew edit emacs-plus@30 后找到 ~:branch => “master”~ 替换成 ~:revision => “6abea4d98d1d964c68a78cb9b5321071da851654”~

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published