Org mode 表格像素对齐

因为我用的dispatcher要求major-mode必须是org-mode或者markdown-mode。现在应该任何derived-mode都可以了。

1 个赞

Org mode生态太大,总有边缘情况 :sweat_smile:

乃这个的前提是等宽字体。

并且做完半宽后,就要开始纠结等高了。。。

还是有错误,使用的是org-agenda然后按n(默认的是 agenda and all todos),对应的

org-agenda-custom-commands

(("n" "Agenda and all TODOs"
  ((agenda "")
   (alltodo ""))))
Debugger entered--Lisp error: (cl-no-applicable-method valign--cell-alignment org-agenda-mode left)
  signal(cl-no-applicable-method (valign--cell-alignment org-agenda-mode left))
  cl-no-applicable-method(#s(cl--generic :name valign--cell-alignment :dispatches ((1 #s(cl--generic-generalizer :name cl--generic-t-generalizer :priority 0 :tagcode-function #f(compiled-function (name &rest _) #<bytecode -0x12a5989a124586b3>) :specializers-function #f(compiled-function (tag &rest _) #<bytecode 0x13d7fdcbedba6a4d>))) (0 #s(cl--generic-generalizer :name cl--generic-derived-generalizer :priority 90 :tagcode-function #f(compiled-function (name) #<bytecode 0xb77cf2931c7006a>) :specializers-function cl--generic-derived-specializers) #s(cl--generic-generalizer :name cl--generic-t-generalizer :priority 0 :tagcode-function #f(compiled-function (name &rest _) #<bytecode -0x12a5989a124586b3>) :specializers-function #f(compiled-function (tag &rest _) #<bytecode 0x13d7fdcbedba6a4d>)))) :method-table (#s(cl--generic-method :specializers ((derived-mode markdown-mode) t) :qualifiers nil :uses-cnm nil :function #f(compiled-function (type hint) "Return how is current cell aligned.\nReturn 'left if aligned left, 'right if aligned right.\nAssumes point is after the left bar (“|”).\nDoesn’t check if we are in a cell.\nTYPE must be 'markdown-mode.  Simply return HINT." #<bytecode -0x136f7c2c327db2e3>)) #s(cl--generic-method :specializers ((derived-mode org-mode) t) :qualifiers nil :uses-cnm nil :function #f(compiled-function (type hint) "Return how is current cell aligned.\nReturn 'left if aligned left, 'right if aligned right.\nAssumes point is after the left bar (“|”).\nDoesn’t check if we are in a cell.\nTYPE must be 'org-mode.  HINT is not used." #<bytecode 0x17439875e6d8ffaa>))) :options nil) org-agenda-mode left)
  apply(cl-no-applicable-method #s(cl--generic :name valign--cell-alignment :dispatches ((1 #s(cl--generic-generalizer :name cl--generic-t-generalizer :priority 0 :tagcode-function #f(compiled-function (name &rest _) #<bytecode -0x12a5989a124586b3>) :specializers-function #f(compiled-function (tag &rest _) #<bytecode 0x13d7fdcbedba6a4d>))) (0 #s(cl--generic-generalizer :name cl--generic-derived-generalizer :priority 90 :tagcode-function #f(compiled-function (name) #<bytecode 0xb77cf2931c7006a>) :specializers-function cl--generic-derived-specializers) #s(cl--generic-generalizer :name cl--generic-t-generalizer :priority 0 :tagcode-function #f(compiled-function (name &rest _) #<bytecode -0x12a5989a124586b3>) :specializers-function #f(compiled-function (tag &rest _) #<bytecode 0x13d7fdcbedba6a4d>)))) :method-table (#s(cl--generic-method :specializers ((derived-mode markdown-mode) t) :qualifiers nil :uses-cnm nil :function #f(compiled-function (type hint) "Return how is current cell aligned.\nReturn 'left if aligned left, 'right if aligned right.\nAssumes point is after the left bar (“|”).\nDoesn’t check if we are in a cell.\nTYPE must be 'markdown-mode.  Simply return HINT." #<bytecode -0x136f7c2c327db2e3>)) #s(cl--generic-method :specializers ((derived-mode org-mode) t) :qualifiers nil :uses-cnm nil :function #f(compiled-function (type hint) "Return how is current cell aligned.\nReturn 'left if aligned left, 'right if aligned right.\nAssumes point is after the left bar (“|”).\nDoesn’t check if we are in a cell.\nTYPE must be 'org-mode.  HINT is not used." #<bytecode 0x17439875e6d8ffaa>))) :options nil) (org-agenda-mode left))
  #f(compiled-function (&rest args) #<bytecode -0x156ad3a2fa595fba>)(org-agenda-mode left)
  apply(#f(compiled-function (&rest args) #<bytecode -0x156ad3a2fa595fba>) org-agenda-mode left)
  valign--cell-alignment(org-agenda-mode left)
  valign-table()
  valign-table-quite()
  valign-initial-alignment(1 1110 t)
  valign--force-align-buffer()
  run-hooks(org-agenda-finalize-hook)
  org-agenda-finalize()
  (let nil (org-agenda-finalize))
  eval((let nil (org-agenda-finalize)))
  org-let(nil (org-agenda-finalize))
  org-agenda-run-series("Agenda and all TODOs" (((agenda "") (alltodo ""))))
  org-agenda(nil)
  funcall-interactively(org-agenda nil)
  call-interactively(org-agenda nil nil)
  command-execute(org-agenda)

org-agenda-mode不是org-mode的子mode。我把它手动加进去了。现在应该ok了。

Debugger entered--Lisp error: (cl-no-applicable-method valign--cell-alignment org-agenda-mode left)
  signal(cl-no-applicable-method (valign--cell-alignment org-agenda-mode left))
  cl-no-applicable-method(#s(cl--generic :name valign--cell-alignment :dispatches ((1 #s(cl--generic-generalizer :name cl--generic-t-generalizer :priority 0 :tagcode-function #f(compiled-function (name &rest _) #<bytecode -0x12a5989a124586b3>) :specializers-function #f(compiled-function (tag &rest _) #<bytecode 0x13d7fdcbedba6a4d>))) (0 #s(cl--generic-generalizer :name cl--generic-derived-generalizer :priority 90 :tagcode-function #f(compiled-function (name) #<bytecode 0xbb84476c305c06a>) :specializers-function cl--generic-derived-specializers) #s(cl--generic-generalizer :name cl--generic-t-generalizer :priority 0 :tagcode-function #f(compiled-function (name &rest _) #<bytecode -0x12a5989a124586b3>) :specializers-function #f(compiled-function (tag &rest _) #<bytecode 0x13d7fdcbedba6a4d>)))) :method-table (#s(cl--generic-method :specializers ((derived-mode markdown-mode) t) :qualifiers nil :uses-cnm nil :function #f(compiled-function (type hint) "Return how is current cell aligned.\nReturn 'left if aligned left, 'right if aligned right.\nAssumes point is after the left bar (“|”).\nDoesn’t check if we are in a cell.\nTYPE must be 'markdown-mode.  Simply return HINT." #<bytecode -0x136f7c2c327db2e3>)) #s(cl--generic-method :specializers ((derived-mode org-mode org-agenda-mode) t) :qualifiers nil :uses-cnm nil :function #f(compiled-function (type hint) "Return how is current cell aligned.\nReturn 'left if aligned left, 'right if aligned right.\nAssumes point is after the left bar (“|”).\nDoesn’t check if we are in a cell.\nTYPE must be 'org-mode.  HINT is not used." #<bytecode -0x6cf536f1d2700b7>))) :options nil) org-agenda-mode left)
  apply(cl-no-applicable-method #s(cl--generic :name valign--cell-alignment :dispatches ((1 #s(cl--generic-generalizer :name cl--generic-t-generalizer :priority 0 :tagcode-function #f(compiled-function (name &rest _) #<bytecode -0x12a5989a124586b3>) :specializers-function #f(compiled-function (tag &rest _) #<bytecode 0x13d7fdcbedba6a4d>))) (0 #s(cl--generic-generalizer :name cl--generic-derived-generalizer :priority 90 :tagcode-function #f(compiled-function (name) #<bytecode 0xbb84476c305c06a>) :specializers-function cl--generic-derived-specializers) #s(cl--generic-generalizer :name cl--generic-t-generalizer :priority 0 :tagcode-function #f(compiled-function (name &rest _) #<bytecode -0x12a5989a124586b3>) :specializers-function #f(compiled-function (tag &rest _) #<bytecode 0x13d7fdcbedba6a4d>)))) :method-table (#s(cl--generic-method :specializers ((derived-mode markdown-mode) t) :qualifiers nil :uses-cnm nil :function #f(compiled-function (type hint) "Return how is current cell aligned.\nReturn 'left if aligned left, 'right if aligned right.\nAssumes point is after the left bar (“|”).\nDoesn’t check if we are in a cell.\nTYPE must be 'markdown-mode.  Simply return HINT." #<bytecode -0x136f7c2c327db2e3>)) #s(cl--generic-method :specializers ((derived-mode org-mode org-agenda-mode) t) :qualifiers nil :uses-cnm nil :function #f(compiled-function (type hint) "Return how is current cell aligned.\nReturn 'left if aligned left, 'right if aligned right.\nAssumes point is after the left bar (“|”).\nDoesn’t check if we are in a cell.\nTYPE must be 'org-mode.  HINT is not used." #<bytecode -0x6cf536f1d2700b7>))) :options nil) (org-agenda-mode left))
  #f(compiled-function (&rest args) #<bytecode -0x9074ea0d9119e3d>)(org-agenda-mode left)
  apply(#f(compiled-function (&rest args) #<bytecode -0x9074ea0d9119e3d>) org-agenda-mode left)
  valign--cell-alignment(org-agenda-mode left)
  valign-table()
  valign-table-quite()
  valign-initial-alignment(1 1960 t)
  valign--force-align-buffer()
  run-hooks(org-agenda-finalize-hook)
  org-agenda-finalize()
  (let nil (org-agenda-finalize))
  eval((let nil (org-agenda-finalize)))
  org-let(nil (org-agenda-finalize))
  org-agenda-run-series("Agenda and all TODOs" (((agenda "") (alltodo ""))))
  org-agenda(nil)
  funcall-interactively(org-agenda nil)
  call-interactively(org-agenda nil nil)
  command-execute(org-agenda)

还是有错误, 这个错误跟上一个一样

Terminal 的 emacs 一直是对齐的吧,哈哈

才发现Emacs有个FIXME说没有我用的这个功能,我还以为实现了😅,抱歉。加了个workaround。

:sweat_smile: 还是报错了…

Debugger entered--Lisp error: (cl-no-applicable-method valign--cell-alignment org-mode left)
  signal(cl-no-applicable-method (valign--cell-alignment org-mode left))
  cl-no-applicable-method(#s(cl--generic :name valign--cell-alignment :dispatches ((1 #s(cl--generic-generalizer :name cl--generic-t-generalizer :priority 0 :tagcode-function #f(compiled-function (name &rest _) #<bytecode -0x12a5989a124586b3>) :specializers-function #f(compiled-function (tag &rest _) #<bytecode 0x13d7fdcbedba6a4d>))) (0 #s(cl--generic-generalizer :name cl--generic-derived-generalizer :priority 90 :tagcode-function #f(compiled-function (name) #<bytecode 0xb95270400f1806a>) :specializers-function cl--generic-derived-specializers) #s(cl--generic-generalizer :name cl--generic-t-generalizer :priority 0 :tagcode-function #f(compiled-function (name &rest _) #<bytecode -0x12a5989a124586b3>) :specializers-function #f(compiled-function (tag &rest _) #<bytecode 0x13d7fdcbedba6a4d>)))) :method-table (#s(cl--generic-method :specializers ((derived-mode markdown-mode) t) :qualifiers nil :uses-cnm nil :function #f(compiled-function (type hint) "Return how is current cell aligned.\nReturn 'left if aligned left, 'right if aligned right.\nAssumes point is after the left bar (“|”).\nDoesn’t check if we are in a cell.\nTYPE must be 'markdown-mode.  Simply return HINT." #<bytecode -0x136f7c2c327db2e3>)) #s(cl--generic-method :specializers ((derived-mode org-agenda-mode) t) :qualifiers nil :uses-cnm nil :function #f(compiled-function (type hint) #<bytecode 0x618f505b5fbe543>)) #s(cl--generic-method :specializers ((derived-mode org-mode org-agenda-mode) t) :qualifiers nil :uses-cnm nil :function #f(compiled-function (type hint) "Return how is current cell aligned.\nReturn 'left if aligned left, 'right if aligned right.\nAssumes point is after the left bar (“|”).\nDoesn’t check if we are in a cell.\nTYPE must be 'org-mode.  HINT is not used." #<bytecode 0x1ae6bf3e9ed8ffb0>))) :options nil) org-mode left)
  apply(cl-no-applicable-method #s(cl--generic :name valign--cell-alignment :dispatches ((1 #s(cl--generic-generalizer :name cl--generic-t-generalizer :priority 0 :tagcode-function #f(compiled-function (name &rest _) #<bytecode -0x12a5989a124586b3>) :specializers-function #f(compiled-function (tag &rest _) #<bytecode 0x13d7fdcbedba6a4d>))) (0 #s(cl--generic-generalizer :name cl--generic-derived-generalizer :priority 90 :tagcode-function #f(compiled-function (name) #<bytecode 0xb95270400f1806a>) :specializers-function cl--generic-derived-specializers) #s(cl--generic-generalizer :name cl--generic-t-generalizer :priority 0 :tagcode-function #f(compiled-function (name &rest _) #<bytecode -0x12a5989a124586b3>) :specializers-function #f(compiled-function (tag &rest _) #<bytecode 0x13d7fdcbedba6a4d>)))) :method-table (#s(cl--generic-method :specializers ((derived-mode markdown-mode) t) :qualifiers nil :uses-cnm nil :function #f(compiled-function (type hint) "Return how is current cell aligned.\nReturn 'left if aligned left, 'right if aligned right.\nAssumes point is after the left bar (“|”).\nDoesn’t check if we are in a cell.\nTYPE must be 'markdown-mode.  Simply return HINT." #<bytecode -0x136f7c2c327db2e3>)) #s(cl--generic-method :specializers ((derived-mode org-agenda-mode) t) :qualifiers nil :uses-cnm nil :function #f(compiled-function (type hint) #<bytecode 0x618f505b5fbe543>)) #s(cl--generic-method :specializers ((derived-mode org-mode org-agenda-mode) t) :qualifiers nil :uses-cnm nil :function #f(compiled-function (type hint) "Return how is current cell aligned.\nReturn 'left if aligned left, 'right if aligned right.\nAssumes point is after the left bar (“|”).\nDoesn’t check if we are in a cell.\nTYPE must be 'org-mode.  HINT is not used." #<bytecode 0x1ae6bf3e9ed8ffb0>))) :options nil) (org-mode left))
  #f(compiled-function (&rest args) #<bytecode -0x48cea4f0689ccd1>)(org-mode left)
  apply(#f(compiled-function (&rest args) #<bytecode -0x48cea4f0689ccd1>) org-mode left)
  valign--cell-alignment(org-mode left)
  #f(compiled-function (type hint) #<bytecode 0x618f505b5fbe543>)(org-agenda-mode left)
  apply(#f(compiled-function (type hint) #<bytecode 0x618f505b5fbe543>) org-agenda-mode left)
  valign--cell-alignment(org-agenda-mode left)
  valign-table()
  valign-table-quite()
  valign-initial-alignment(1 1019 t)
  valign--force-align-buffer()
  run-hooks(org-agenda-finalize-hook)
  org-agenda-finalize()
  (let nil (org-agenda-finalize))
  eval((let nil (org-agenda-finalize)))
  org-let(nil (org-agenda-finalize))
  org-agenda-run-series("Agenda and all TODOs" (((agenda "") (alltodo ""))))
  org-agenda(nil)
  funcall-interactively(org-agenda nil)
  call-interactively(org-agenda nil nil)
  command-execute(org-agenda)

是啊,terminal一直是对齐的,楼主gui对齐原理和terminal不一样,如果同时使用gui和terminal,那至少有一个是不齐的。

很少用org table。从上面复制粘贴了一段。 效果不错 :+1:

问下我的终端什么也没弄,就能自动对齐了。是这样吗?

上面的是GUI, 下面的是终端。自己很少用终端

太厉害了,非常好用。

终端不需要这个,在终端负责显示的是模拟器,自动就能对齐

发现一个问题

image

无法对其呢

把表格发我看看?

确定是最新版吗?

image

今天换了个环境,确保valign 是下载的最新版。

文本文件系统不允许上传:(

我也发现一个bug:自己创建的table无法对齐,复制粘贴的table可以对齐。 原来根本的问题是表格左边没有字符才能对齐,要紧靠左边框。

是的,确定是最新版,而且Org Mode也用的是 master 分支最新的