0

我的问题来自我期望一个可以将 org-mode 表转换为 ditaa 图的函数。我尝试做的是:

  1. 找到“|” 如果左/右/上/下有任何“-”,将其更改为“+”
  2. 如果没有“|”,则查找“+” 在左/右/上/下,将其更改为“-”

谁能告诉我如何搜索上方/下方的字符或整个功能?

4

2 回答 2

0

首先,感谢@legoscia 的原始解决方案。

当我尝试(下一行)/(上一行)时,我遇到了一些问题,例如“缓冲区结束,缓冲区开始”。然后我在elisp手册中搜索。它建议使用前锋线。然后我在这里得到了解决方案:

(defun get-char-below (&optional point)
  "Return the character one line down from POINT.
If POINT is nil or omitted, use the current position of point."
  (save-excursion
    (when point
      (goto-char point))
    (let ((column (current-column)))
      (if (= (forward-line 1) 0)
          (if (= column (move-to-column column))
            (char-after)
          nil)
        nil))))
于 2014-04-04T01:43:36.657 回答
0

您可以使用这样的函数来检查下一行的内容:

(defun get-char-on-next-line (&optional point)
  "Return the character one line down from POINT.
If POINT is nil or omitted, use the current position of point."
  (save-excursion
    (when point
      (goto-char point))
    (let ((column (current-column))
          (line-move-visual nil))
      ;; next-line preserves the current column if possible
      (next-line)
      (when (= column (current-column))
        (char-after)))))

替换nextprevious相反的功能。

于 2014-04-03T10:52:26.527 回答