Org mode 表格像素对齐

我这里可以呀。

Debugger entered--Lisp error: (error "Specified window is not displaying the current buffer")
  font-at(11)
  valign--glyph-width-at-point()
  valign--pixel-width-from-to(11 12)
  valign--cell-width()
  valign--calculate-column-width-list(322)
  valign-table()
  valign-initial-alignment(1 2146 t)
  valign--org-flag-region-advice(1 2146 nil org-hide-block)
  apply(valign--org-flag-region-advice (1 2146 nil org-hide-block))
  org-flag-region(1 2146 nil org-hide-block)
  org-show-all()
  org-set-startup-visibility()
  org-mode()
  set-auto-mode-0(org-mode nil)
  #f(compiled-function (&optional keep-mode-if-same) "Select major mode appropriate for current buffer.\n\nTo find the right major mode, this function checks for a -*- mode tag\nchecks for a `mode:' entry in the Local Variables section of the file,\nchecks if it uses an interpreter listed in `interpreter-mode-alist',\nmatches the buffer beginning against `magic-mode-alist',\ncompares the filename against the entries in `auto-mode-alist',\nthen matches the buffer beginning against `magic-fallback-mode-alist'.\n\nIf `enable-local-variables' is nil, or if the file name matches\n`inhibit-local-variables-regexps', this function does not check\nfor any mode: tag anywhere in the file.  If `local-enable-local-variables'\nis nil, then the only mode: tag that can be relevant is a -*- one.\n\nIf the optional argument KEEP-MODE-IF-SAME is non-nil, then we\nset the major mode only if that would change it.  In other words\nwe don't actually set it to the same mode the buffer already has." #<bytecode 0x1b425b>)()
  apply(#f(compiled-function (&optional keep-mode-if-same) "Select major mode appropriate for current buffer.\n\nTo find the right major mode, this function checks for a -*- mode tag\nchecks for a `mode:' entry in the Local Variables section of the file,\nchecks if it uses an interpreter listed in `interpreter-mode-alist',\nmatches the buffer beginning against `magic-mode-alist',\ncompares the filename against the entries in `auto-mode-alist',\nthen matches the buffer beginning against `magic-fallback-mode-alist'.\n\nIf `enable-local-variables' is nil, or if the file name matches\n`inhibit-local-variables-regexps', this function does not check\nfor any mode: tag anywhere in the file.  If `local-enable-local-variables'\nis nil, then the only mode: tag that can be relevant is a -*- one.\n\nIf the optional argument KEEP-MODE-IF-SAME is non-nil, then we\nset the major mode only if that would change it.  In other words\nwe don't actually set it to the same mode the buffer already has." #<bytecode 0x1b425b>) nil)
  so-long--set-auto-mode(#f(compiled-function (&optional keep-mode-if-same) "Select major mode appropriate for current buffer.\n\nTo find the right major mode, this function checks for a -*- mode tag\nchecks for a `mode:' entry in the Local Variables section of the file,\nchecks if it uses an interpreter listed in `interpreter-mode-alist',\nmatches the buffer beginning against `magic-mode-alist',\ncompares the filename against the entries in `auto-mode-alist',\nthen matches the buffer beginning against `magic-fallback-mode-alist'.\n\nIf `enable-local-variables' is nil, or if the file name matches\n`inhibit-local-variables-regexps', this function does not check\nfor any mode: tag anywhere in the file.  If `local-enable-local-variables'\nis nil, then the only mode: tag that can be relevant is a -*- one.\n\nIf the optional argument KEEP-MODE-IF-SAME is non-nil, then we\nset the major mode only if that would change it.  In other words\nwe don't actually set it to the same mode the buffer already has." #<bytecode 0x1b425b>))
  apply(so-long--set-auto-mode #f(compiled-function (&optional keep-mode-if-same) "Select major mode appropriate for current buffer.\n\nTo find the right major mode, this function checks for a -*- mode tag\nchecks for a `mode:' entry in the Local Variables section of the file,\nchecks if it uses an interpreter listed in `interpreter-mode-alist',\nmatches the buffer beginning against `magic-mode-alist',\ncompares the filename against the entries in `auto-mode-alist',\nthen matches the buffer beginning against `magic-fallback-mode-alist'.\n\nIf `enable-local-variables' is nil, or if the file name matches\n`inhibit-local-variables-regexps', this function does not check\nfor any mode: tag anywhere in the file.  If `local-enable-local-variables'\nis nil, then the only mode: tag that can be relevant is a -*- one.\n\nIf the optional argument KEEP-MODE-IF-SAME is non-nil, then we\nset the major mode only if that would change it.  In other words\nwe don't actually set it to the same mode the buffer already has." #<bytecode 0x1b425b>) nil)
  #f(advice-wrapper :around #f(compiled-function (&optional keep-mode-if-same) "Select major mode appropriate for current buffer.\n\nTo find the right major mode, this function checks for a -*- mode tag\nchecks for a `mode:' entry in the Local Variables section of the file,\nchecks if it uses an interpreter listed in `interpreter-mode-alist',\nmatches the buffer beginning against `magic-mode-alist',\ncompares the filename against the entries in `auto-mode-alist',\nthen matches the buffer beginning against `magic-fallback-mode-alist'.\n\nIf `enable-local-variables' is nil, or if the file name matches\n`inhibit-local-variables-regexps', this function does not check\nfor any mode: tag anywhere in the file.  If `local-enable-local-variables'\nis nil, then the only mode: tag that can be relevant is a -*- one.\n\nIf the optional argument KEEP-MODE-IF-SAME is non-nil, then we\nset the major mode only if that would change it.  In other words\nwe don't actually set it to the same mode the buffer already has." #<bytecode 0x1b425b>) so-long--set-auto-mode)()
  apply(#f(advice-wrapper :around #f(compiled-function (&optional keep-mode-if-same) "Select major mode appropriate for current buffer.\n\nTo find the right major mode, this function checks for a -*- mode tag\nchecks for a `mode:' entry in the Local Variables section of the file,\nchecks if it uses an interpreter listed in `interpreter-mode-alist',\nmatches the buffer beginning against `magic-mode-alist',\ncompares the filename against the entries in `auto-mode-alist',\nthen matches the buffer beginning against `magic-fallback-mode-alist'.\n\nIf `enable-local-variables' is nil, or if the file name matches\n`inhibit-local-variables-regexps', this function does not check\nfor any mode: tag anywhere in the file.  If `local-enable-local-variables'\nis nil, then the only mode: tag that can be relevant is a -*- one.\n\nIf the optional argument KEEP-MODE-IF-SAME is non-nil, then we\nset the major mode only if that would change it.  In other words\nwe don't actually set it to the same mode the buffer already has." #<bytecode 0x1b425b>) so-long--set-auto-mode) nil)
  set-auto-mode()
  normal-mode(t)
  #f(compiled-function (&optional error warn noauto after-find-file-from-revert-buffer nomodes) "Called after finding a file and by the default revert function.\nSets buffer mode, parses file-local and directory-local variables.\nOptional args ERROR, WARN, and NOAUTO: ERROR non-nil means there was an\nerror in reading the file.  WARN non-nil means warn if there\nexists an auto-save file more recent than the visited file.\nNOAUTO means don't mess with auto-save mode.\nFourth arg AFTER-FIND-FILE-FROM-REVERT-BUFFER is ignored\n(see `revert-buffer-in-progress-p' for similar functionality).\nFifth arg NOMODES non-nil means don't alter the file's modes.\nFinishes by calling the functions in `find-file-hook'\nunless NOMODES is non-nil." #<bytecode 0x1b3a7f>)(nil t)
  apply(#f(compiled-function (&optional error warn noauto after-find-file-from-revert-buffer nomodes) "Called after finding a file and by the default revert function.\nSets buffer mode, parses file-local and directory-local variables.\nOptional args ERROR, WARN, and NOAUTO: ERROR non-nil means there was an\nerror in reading the file.  WARN non-nil means warn if there\nexists an auto-save file more recent than the visited file.\nNOAUTO means don't mess with auto-save mode.\nFourth arg AFTER-FIND-FILE-FROM-REVERT-BUFFER is ignored\n(see `revert-buffer-in-progress-p' for similar functionality).\nFifth arg NOMODES non-nil means don't alter the file's modes.\nFinishes by calling the functions in `find-file-hook'\nunless NOMODES is non-nil." #<bytecode 0x1b3a7f>) (nil t))
  (if (setq doom-large-file-p (and buffer-file-name (not doom-large-file-p) (file-exists-p buffer-file-name) (condition-case nil (progn (> (nth 7 (file-attributes buffer-file-name)) (* 1024 1024 (assoc-default buffer-file-name doom-large-file-size-alist ...)))) (error nil)))) (prog1 (apply orig-fn args) (if (memq major-mode doom-large-file-excluded-modes) (setq doom-large-file-p nil) (if (fboundp (quote so-long-minor-mode)) (progn (so-long-minor-mode 1))) (message "Large file detected! Cutting a few corners to improve performance..."))) (apply orig-fn args))
  doom--optimize-for-large-files-a(#f(compiled-function (&optional error warn noauto after-find-file-from-revert-buffer nomodes) "Called after finding a file and by the default revert function.\nSets buffer mode, parses file-local and directory-local variables.\nOptional args ERROR, WARN, and NOAUTO: ERROR non-nil means there was an\nerror in reading the file.  WARN non-nil means warn if there\nexists an auto-save file more recent than the visited file.\nNOAUTO means don't mess with auto-save mode.\nFourth arg AFTER-FIND-FILE-FROM-REVERT-BUFFER is ignored\n(see `revert-buffer-in-progress-p' for similar functionality).\nFifth arg NOMODES non-nil means don't alter the file's modes.\nFinishes by calling the functions in `find-file-hook'\nunless NOMODES is non-nil." #<bytecode 0x1b3a7f>) nil t)
  apply(doom--optimize-for-large-files-a #f(compiled-function (&optional error warn noauto after-find-file-from-revert-buffer nomodes) "Called after finding a file and by the default revert function.\nSets buffer mode, parses file-local and directory-local variables.\nOptional args ERROR, WARN, and NOAUTO: ERROR non-nil means there was an\nerror in reading the file.  WARN non-nil means warn if there\nexists an auto-save file more recent than the visited file.\nNOAUTO means don't mess with auto-save mode.\nFourth arg AFTER-FIND-FILE-FROM-REVERT-BUFFER is ignored\n(see `revert-buffer-in-progress-p' for similar functionality).\nFifth arg NOMODES non-nil means don't alter the file's modes.\nFinishes by calling the functions in `find-file-hook'\nunless NOMODES is non-nil." #<bytecode 0x1b3a7f>) (nil t))
  #f(advice-wrapper :around #f(compiled-function (&optional error warn noauto after-find-file-from-revert-buffer nomodes) "Called after finding a file and by the default revert function.\nSets buffer mode, parses file-local and directory-local variables.\nOptional args ERROR, WARN, and NOAUTO: ERROR non-nil means there was an\nerror in reading the file.  WARN non-nil means warn if there\nexists an auto-save file more recent than the visited file.\nNOAUTO means don't mess with auto-save mode.\nFourth arg AFTER-FIND-FILE-FROM-REVERT-BUFFER is ignored\n(see `revert-buffer-in-progress-p' for similar functionality).\nFifth arg NOMODES non-nil means don't alter the file's modes.\nFinishes by calling the functions in `find-file-hook'\nunless NOMODES is non-nil." #<bytecode 0x1b3a7f>) doom--optimize-for-large-files-a)(nil t)
  apply(#f(advice-wrapper :around #f(compiled-function (&optional error warn noauto after-find-file-from-revert-buffer nomodes) "Called after finding a file and by the default revert function.\nSets buffer mode, parses file-local and directory-local variables.\nOptional args ERROR, WARN, and NOAUTO: ERROR non-nil means there was an\nerror in reading the file.  WARN non-nil means warn if there\nexists an auto-save file more recent than the visited file.\nNOAUTO means don't mess with auto-save mode.\nFourth arg AFTER-FIND-FILE-FROM-REVERT-BUFFER is ignored\n(see `revert-buffer-in-progress-p' for similar functionality).\nFifth arg NOMODES non-nil means don't alter the file's modes.\nFinishes by calling the functions in `find-file-hook'\nunless NOMODES is non-nil." #<bytecode 0x1b3a7f>) doom--optimize-for-large-files-a) (nil t))
  #f(advice-wrapper :before #f(advice-wrapper :around #f(compiled-function (&optional error warn noauto after-find-file-from-revert-buffer nomodes) "Called after finding a file and by the default revert function.\nSets buffer mode, parses file-local and directory-local variables.\nOptional args ERROR, WARN, and NOAUTO: ERROR non-nil means there was an\nerror in reading the file.  WARN non-nil means warn if there\nexists an auto-save file more recent than the visited file.\nNOAUTO means don't mess with auto-save mode.\nFourth arg AFTER-FIND-FILE-FROM-REVERT-BUFFER is ignored\n(see `revert-buffer-in-progress-p' for similar functionality).\nFifth arg NOMODES non-nil means don't alter the file's modes.\nFinishes by calling the functions in `find-file-hook'\nunless NOMODES is non-nil." #<bytecode 0x1b3a7f>) doom--optimize-for-large-files-a) doom-first-file-hook-h)(nil t)
  apply(#f(advice-wrapper :before #f(advice-wrapper :around #f(compiled-function (&optional error warn noauto after-find-file-from-revert-buffer nomodes) "Called after finding a file and by the default revert function.\nSets buffer mode, parses file-local and directory-local variables.\nOptional args ERROR, WARN, and NOAUTO: ERROR non-nil means there was an\nerror in reading the file.  WARN non-nil means warn if there\nexists an auto-save file more recent than the visited file.\nNOAUTO means don't mess with auto-save mode.\nFourth arg AFTER-FIND-FILE-FROM-REVERT-BUFFER is ignored\n(see `revert-buffer-in-progress-p' for similar functionality).\nFifth arg NOMODES non-nil means don't alter the file's modes.\nFinishes by calling the functions in `find-file-hook'\nunless NOMODES is non-nil." #<bytecode 0x1b3a7f>) doom--optimize-for-large-files-a) doom-first-file-hook-h) (nil t))
  after-find-file(nil t)
  find-file-noselect-1(#<buffer org_align.org> "~/org_align.org" nil nil "~/org_align.org" (4471771 2065))
  find-file-noselect("/home/mls/org_align.org" nil nil nil)
  find-file("/home/mls/org_align.org")
  counsel-find-file-action("/home/mls/org_align.org")
  ivy-call()
  ivy-read("Find file: " read-file-name-internal :matcher counsel--find-file-matcher :initial-input nil :action counsel-find-file-action :preselect nil :require-match confirm-after-completion :history file-name-history :keymap (keymap (remap keymap (undo . counsel-find-file-undo)) (96 lambda (&optional arg) "nil (`nil')" (interactive "p") (if (string= "" ivy-text) (execute-kbd-macro (kbd "M-o b")) (self-insert-command arg))) (C-backspace . counsel-up-directory) (67108991 . counsel-up-directory)) :caller counsel-find-file)
  counsel--find-file-1("Find file: " nil counsel-find-file-action counsel-find-file)
  counsel-find-file()
  funcall-interactively(counsel-find-file)
  call-interactively(counsel-find-file nil nil)
  command-execute(counsel-find-file)

首次打开不对齐,关闭文件重新打开一直报这个错误。

原来是这样,我可能知道为啥了。

能否保留 hline 的 虚线和加号?

|------------+---------------------------------------------------+----------|

希望能保留所有(多个)hline 的 虚线和加号。

1 个赞

或者把竖线连起来,变成实线。一虚一实,看着确实有点奇怪。

做了很多细节调整,现在应该不会出现边缘情况了。

虚线不能,技术原因。加号的话加上挺丑的,现在的竖线我感觉更好看,

你试试最新版,图上的情况是有bug。

这个也不可能,因为即使普通行我改用unicode连起来了,如果行内有图片之类的东西让这行变高,就又不连着了,反而难看。(试了一下,unicode也不能让普通行连起来)

1 个赞

(require 'valign) error:

Debugger entered--Lisp error: (void-variable valign-mode)
  #f(compiled-function (var val) #<bytecode 0x448c23d9>)(valign-separator-row-style multi-column)
  custom-initialize-reset(valign-separator-row-style (funcall (function #f(compiled-function () #<bytecode 0x448c23c5>))))
  custom-declare-variable(valign-separator-row-style (funcall (function #f(compiled-function () #<bytecode 0x448c23c5>))) "The style of the separator row of a table.\nValign can render it as “|-----------|”\nor as “|-----|-----|”.  Set this option to 'single-column\nfor the former, and 'multi-column for the latter." :set #f(compiled-function (var val) #<bytecode 0x448c23d9>) :type (choice (const :tag "Multiple columns" (quote multi-column)) (const :tag "A single column" (quote single-column))) :group valign)
  byte-code("\300\301\302\303\304DD\305\306\307\310\311\312\313&\011\207" [custom-declare-variable valign-separator-row-style funcall function #f(compiled-function () #<bytecode 0x448c23c5>) "The style of the separator row of a table.\nValign can render it as “|-----------|”\nor as “|-----|-----|”.  Set this option to 'single-column\nfor the former, and 'multi-column for the latter." :set #f(compiled-function (var val) #<bytecode 0x448c23d9>) :type (choice (const :tag "Multiple columns" (quote multi-column)) (const :tag "A single column" (quote single-column))) :group valign] 10)
  require(valign)
  eval((require (quote valign)) nil)
  elisp--eval-last-sexp(nil)
  #f(compiled-function (eval-last-sexp-arg-internal) "Evaluate sexp before point; print value in the echo area.\nInteractively, with a non `-' prefix argument, print output into\ncurrent buffer.\n\nNormally, this function truncates long output according to the\nvalue of the variables `eval-expression-print-length' and\n`eval-expression-print-level'.  With a prefix argument of zero,\nhowever, there is no such truncation.\nInteger values are printed in several formats (decimal, octal,\nand hexadecimal).  When the prefix argument is -1 or the value\ndoesn't exceed `eval-expression-print-maximum-character', an\ninteger value is also printed as a character of that codepoint.\n\nIf `eval-expression-debug-on-error' is non-nil, which is the default,\nthis command arranges for all errors to enter the debugger." (interactive "P") #<bytecode 0x400e2483>)(nil)
  apply(#f(compiled-function (eval-last-sexp-arg-internal) "Evaluate sexp before point; print value in the echo area.\nInteractively, with a non `-' prefix argument, print output into\ncurrent buffer.\n\nNormally, this function truncates long output according to the\nvalue of the variables `eval-expression-print-length' and\n`eval-expression-print-level'.  With a prefix argument of zero,\nhowever, there is no such truncation.\nInteger values are printed in several formats (decimal, octal,\nand hexadecimal).  When the prefix argument is -1 or the value\ndoesn't exceed `eval-expression-print-maximum-character', an\ninteger value is also printed as a character of that codepoint.\n\nIf `eval-expression-debug-on-error' is non-nil, which is the default,\nthis command arranges for all errors to enter the debugger." (interactive "P") #<bytecode 0x400e2483>) nil)
  eval-last-sexp(nil)
  funcall-interactively(eval-last-sexp nil)
  call-interactively(eval-last-sexp nil nil)
  command-execute(eval-last-sexp)

现在可以了,customize也能正常工作了:设置style会自动刷新。

markdown-mode的表格也可以支持一下嘛?

markdown有统一的table格式吗?

这个吗: Extended Syntax | Markdown Guide

是的! 字数补丁

valign--end-of-table 要求表格的|字符必须是该行第一个字符,前面不可以有空格。应该支持整个表格有缩进的情况吗?

我这里出现了奇怪的对齐问题:

对应的org文件如下

** 2017-11 十一月
*** 2017-11-12 星期日
**** Anime
***** 10 月新番
      所有时间均为北京时间
|------------------+----------------------------+-----------+------+-------+----------|
| 此花亭奇谈       | 轻百合,兽耳萝莉           | 周四 0000 | B 站 | 10.05 | 追!     |
| Just Because     | 鸭志田一,校园,恋爱       | 周五 0000 | B 站 | 10.06 | 追!     |
| 少女终末旅行     | 废土,公路,百合           | 周五 2200 | B 站 | 10.06 | 追!     |
| 新 奇诺之旅      | 有生之年,公路,旅行       | 周六 0100 | 下载 | 10.07 | 追!     |
| 结成友奈是勇者   | 战斗,致郁,残疾部         | 周六 0325 | B 站 | 10.07 | 等新剧情 |
| 调教咖啡厅       | 日常,喜剧,咖啡厅,芳文社 | 周日 0100 | B 站 | 10.08 | 追!     |
| 舞动青春         | 青春,运动,社交舞         | 周日 0208 | B 站 |  在播 | 追!     |
| 3 月的狮子第二季 | 将棋,励志,治愈,感情     | 周日 0300 | B 站 | 10.15 | 追!     |
| 幻界战线第二季   | 热血,奇幻,异能           | 周日 0308 | B 站 | 10.08 | 追!     |
| 如果有妹妹就好了 | 恋爱,喜剧,丧病妹控       | 周日 2300 | B 站 | 10.08 | 追!     |
|                  |                            |           |      |       |          |
|------------------+----------------------------+-----------+------+-------+----------|
***** 可能会追的番
      - 宝石之国
* 2018
** 2018-02 二月
*** 2018-02-12 星期一
**** Anime
***** 1 月新番
      所有时间均为北京时间,DARLING in the FRANXX 是半年番。
|--------------------------+----------------------------+-----------+------+-------+----------|
| 龙王的工作!             | 将棋、萝莉、后宫           | 周一 2230 | B 站 | 01.08 | 追       |
| 比宇宙更远的地方         | 青春、冒险、旅行、南极     | 周二 2100 | B 站 | 01.02 | 赞爆了! |
| 齐木楠雄的灾难           | 校园、喜剧、异能、神经病   | 周三 0135 | 下载 | 01.17 | 追       |
| 紫罗兰永恒花园           | 成长、爱情、凄美、战争会议 | 周四 0000 | B 站 | 01.11 | 追!     |
| 爱吃拉面的小泉同学       | 日常、美食、反差、轻百合   | 周四 1900 | B 站 | 01.04 | 追       |
| 摇曳露营                 | 日常、治愈、户外、轻百合   | 周四 2330 | 下载 | 01.04 | 追!     |
| 爆肝工程师的异世界狂想曲 | 穿越、旅游、美食、后宫     | 周五 0030 | 下载 | 01.12 | 追……     |
| DARLING in the FRANXX    | 科幻、机战、“国家队”       | 周日 0000 | 下载 | 01.14 | 追!     |
| 3 月的狮子第二季         | 将棋,励志,治愈,感情     | 周日 0300 | B 站 |  在播 | 追!     |
|                          |                            |           |      |       |          |
|--------------------------+----------------------------+-----------+------+-------+----------|
***** 可能会追/补的番
|---------------------+------------------------------+-----------+------+-------+----------|
| 刻刻                | 悬疑、异能、战斗、宗教       | 周一 0000 | B 站 | 01.08 | 据说不错 |
| 擅长捉弄的高木同学  | 校园、恋爱、喜剧、狗粮       | 周一 2300 | 下载 | 01.08 | 攒着?   |
| 恋如雨止            | 青春、恋爱、忘年恋、倒 A 档  | 周五 0300 | 下载 | 01.12 | 攒着?   |
| 魔卡少女樱 透明牌篇 | 魔法、恋爱、少女漫、有生之年 | 周日 0900 | 下载 | 01.07 | 攒着!   |
|---------------------+------------------------------+-----------+------+-------+----------|

emmm我这里没法复现,能不能确认一下是不是最新版?

现在支持了。

确实有对不齐的问题,但不好重现,我在cell 里面乱加空格,偶尔可以测试处理

|--------------------------+--------------------------+-----------+------+-------+------|
| 摇曳露营                 | 日常、治愈、户外、轻百合 | 周四 2330 | 下载 | 01.04 | 追! |
| 爆肝工程师的异世界狂想曲 | 穿越、旅游、美食、后宫   | 周五 0030 | 下载 | 01.12 | 追   |
| DARLING in the FRANXX    | 科幻、机战、“国家队”     | 周日 0000 | 下载 | 01.14 | 追! |
|--------------------------+--------------------------+-----------+------+-------+------|

我在“爆肝工程师”前面加3个空格,然后 C-c C-c, 就对不齐了。

这个也复现不了。


不过我发现了一个问题,目前还没法解决,就是对TAB字符没法处理。Emacs返回的TAB的宽度不对。这玩意还不好解决。Emacs是在redisplay的时候动态计算tab的宽度的,想要计算精确的tab宽度只能从最左边一路计算。

感谢迅捷的更新! 我刚pull了一下最新版,仍然存在相应的问题。用的是Archlinuxcn源里的Emacs 28,Doom。table内的字体是文泉驿等宽正黑。