Emacs FAQ

Emacs FAQ

Emacs FAQ

before ask, check 2:

emacs报包的签名错误

问题:Emacs: Failed to verify signature xxx.sig 办法: 重命名~/.emacs.d/elpa/gnupg,M-x package-refresh-contents, 记得git不要带上这个文件夹

emacs如何放大缩小字体

C-x C-= C-x C– M-x text-scale-adust 自适应

C-c &是干什么的

使用C-h b C-c &发现是org-mark-ring-goto 使用C-h f org-mark-ring-goto org-mark-ring-goto is an interactive compiled Lisp function in ‘org.el’.

It is bound to C-c &.

(org-mark-ring-goto &optional N)

Jump to the previous position in the mark ring. With prefix arg N, jump back that many stored positions. When called several times in succession, walk through the entire ring. Org mode commands jumping to a different position in the current file, or to another Org file, automatically push the old position onto the ring. 目测是跳转到刚刚的打开页面, 也就是返回

  • publish org files

see https://orgmode.org/worg/org-tutorials/org-publish-html-tutorial.html

  • 模版自动插入 一种方式是auto-insert, 也可以通过yasnipet或者org-capture的模版实现

多窗口如何放大缩小

首先鼠标就可以拖动哈 命令行操作,

左右分屏的时候

使用C-x } enlarge horizontally 使用C-x { shrink horizontally

上下分屏的时候

使用C-x ^ enlarge vertically 使用C-x - shrink vertically

平衡

使用C-x + 平衡高度宽度

重复之前的动作(使用所有emacs操作)

C-x z

emacs启动时间优化

M-x emacs-init-time 56.530494s 震惊了 后来10s 急需优化一下,记录一下优化过程 我重新启动,发现停留时间长的有org-roam-ui, 估计默认开启了,决定关掉,因为确实很少用 直接删掉配置不行,所以确认参数是org-roam-ui-mode 进行(setq org-roam-ui-mode nil)即可 发现还是好了不少了哈 继续看messages里面信息

emacs org-mode里面回车整体换行是咋回事

尝试把eletric那个mode关闭或者C-u C-y试试

emacs里面org-mode怎么在org里面使用语言mode编写代码

用C-c '

windows两个窗口之间会出现分界线,不好看

indicator相关的display干掉

roam node候选框没有,但是我还想新建怎么办

Ctrl-Enter

emacs org-mode babel C时候,等字符变成|

类似这样

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
  #include <stdio.h>
  #include <string.h>

  int main() {
    char s1[] = "hello ";
    char s2[] = "liuliancao";

    char s3[] = "";
    strcpy(s3, s1);

    printf("strcopy(s3, s1), s3 is %s\n", s3);

    printf("strcat(s1, s2) is %s\n", strcat(s1, s2));

    printf("strlen(s1) is %d\n", strlen(s1));

    printf("strcmp(%s,%s) is %d\n", s1, s1, strcmp(s1, s1));
    printf("strcmp(%s,%s) is %d\n", s1, s2, strcmp(s1, s2));

  }
strcopy(s3, s1), s3 is hello
strcat(s1, s2) is hello ello
strlen(s1) is 11
strcmp(hello ello ,hello ello ) is 0
strcmp(hello ello ,ello ) is 3

先分析下原因吧,把这段放到bash执行必然是可以的,所以是emacs环境变量相关和bash不一致 ,而这部分是babel相关的,所以检查下babel相关的变量

emacs里面如何注释

M-x comment-dwim

undo的时候有很多,怎么来回切换和方便

1
2
3
4
(use-package undo-tree
  :ensure t
  :init
  (global-undo-tree-mode t))

再使用C-x u就会有一个树选择,当然也可以Ctrl+/来直接回到上一次

emacs剪切板的历史记录如何获取

emacs会把copy的内容放进kill ring里面,通过C-y实现粘贴

通过M-y可以选择到之前的内容

emacs发邮件

整体观察下来,最近尝试用下gnus

gnus我建议先阅读下文档emacswiki gnusgnus tutorial

首先直接M-x gnus打开gnus会报错,因为没有任何group设置

gnus在线pdf文档

https://sqrtminusone.xyz/posts/2021-02-27-gmail/ https://allsyed.com/posts/manage-gmail-with-emacs-part-1/ 配置了gmail报错

创建~/.gnus.el配置文件

这里还是以gmail为例先配置下

GPG的部分在这里可以先设置下Security也可以按照下面github的链接参考下

首先按照这里提示把gmail二次认证打开并生成设备码 https://github.com/kensanata/ggg#getting-a-password-for-gmail

emacs打开~/.authinfo.gpg,emacs自己会进行gpg处理, 注意到u的那行,按下m,表示只能自己访问

qqmail可以

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
  (use-package gnus
    :ensure t
    :config
    ;; gmail accounts
    ;; (setq user-email-address "liuliancao@gmail.com")
    ;; (setq user-full-name "liuliancao")
    ;; (setq gnus-select-method
    ;;       '(nnimap "gmail"
    ;;                (nnimap-address "imap.gmail.com")
    ;;                (nnimap-server-port 993)
    ;;                (nnimap-stream ssl)))
    ;; (setq smtpmail-smtp-server "smtp.gmail.com")
    ;; (setq smtp-smtp-service 587)
    ;; (setq message-mail-function 'smtpmail-send-it)
    ;; (setq gnus-message-archive-group nil)
    ;; (setq mml-secure-openpgp-encrypt-to-self t)
    ;; (add-hook 'message-setup-hook 'mml-secure-message-encrypt)
    (setq gnus-select-method
      '(nnimap "qqmail"
               (nnimap-address "imap.qq.com")
               (nnimap-user "luqixue@qq.com") ;; atention nnimap-user must be full with @
               (nnimap-server-port 993)
               (nnimap-stream ssl)
               ))
     (setq send-mail-function 'smtpmail-send-it
            user-mail-address "luqixue@qq.com"
            user-full-name "lqx"
            smtpmail-smtp-server "smtp.qq.com"
            smtpmail-smtp-service 465
            smtpmail-stream-type 'ssl
            )
      )

TODO emacs另一个buffer翻页

待研究 暂时用C-M-v

TODO 一边pdf翻页一遍记笔记

自动换行

设置auto-fill-mode 文章段落调用M-x fill-region

minibuffer命令历史翻页

M-n或者M-p

org mode相关

建议阅读orgguide,或者pdf下下来

emacs org mode显示图片

C-c C-x C-v 或者M-x org-toggle-inline-images

org-mode里面图片大小调整

使用

org mode展开和折叠

org-cycle表示org mode里面TAB用于进行状态转换 也就是说,如果在顶部按TAB三下状态分别会变化 FOLDED, CHILDREN, SUBTREE,再按又会陷入循环

一般想全部折叠按Shift-TAB 想全部展开按C-u C-u C-u TAB 如果希望org文件默认开启的时候展开则增加头

#+STARTUP: content

演示的时候org太多,某一个heading和里面的内容拿出来置顶

C-n x s 只显示这个heading C-n x w 回到之前的展开状态

org mode里面快速根据现在的内容生成表格

1
C-c |		org-table-create-or-convert-from-region

org mode里面表格上下或者左右互换

注意S是shift

1
2
3
4
5
<S-down>	org-shiftdown
<S-left>	org-shiftleft
<S-return>	org-table-copy-down
<S-right>	org-shiftright
<S-up>		org-shiftup

S-return很有意思,相当于excel里面的自增

org mode对list任务希望记录百分比或者分数进度

在title headline后面加[/]或者[%], 按C-c C-c就可以显示了

在类似开头- 的list后面加一个[ ],按C-c C-c就会打一个X表示做完了,再次按下还原

org mode里面需要把文件放到agenda页面或者移除

1
2
C-c [		org-agenda-file-to-front
C-c ]		org-remove-file

org mode表格复制到下方

s-enter(shift+enter)

org插入一个excel复制的表格

先copy,然后按下C-|或者搜索convert-from-region

company补全的时候大小写不敏感

1
  (setq company-dabbrev-ignore-case nil)

代码想折叠怎么办

使用hs-minor-mode C-c @ C-d折叠 C-c @ C-s展开 觉得快捷键麻烦可以M-x hs-搜索下就好了

vim c-v的效果,批量列编辑

使用retangle mark C-x SPC C-n C-p move C-t YOUR_STRING RET

emacs里面的书签记录文件位置

记录书签 C-x r m 查找书签 C-x r b

对一些行 自动转成列表todo

C-c -

eglot报错github eglot eglot–connect: Symbol’s function definition is void: project-root

如果是临时安装,建议重启一下emacs

emacs org mode怎么做重复任务呢

https://orgmode.org/manual/Repeated-tasks.html

比如一个任务要每天提醒,在日期后面加一个+1d就可以 SCHEDULED: <2022-11-30 三 +1d>

emacs导入html内嵌base64 image

1
#+PANDOC_OPTIONS: self-contained:t

使用pandoc的时候 加上这个开头

agenda上一周

按b

emacs导出时候下划线变成下标

1
#+OPTIONS: ^:nil

每一行转成列表to list

C-c -,更换格式,S-right

删除匹配的行

M-x flush-lines

emacs增加环境变量

1
(add-to-list 'exec-path "~/go/bin")

emacs补全的时候禁用补全