0

org-toggle-inline-images次のようなリンクを含む新しいバッファを開くたびに関数を実行したい: file:folder/file.jpg.

これを行う方法 ?

4

1 に答える 1

3

これを試して:

(add-hook 'org-mode-hook 'my-org-mode-hook)
(defun my-org-mode-hook ()
  (save-excursion
    (save-restriction
      (goto-char (point-min))
      (when (re-search-forward "file:folder/file\\.jpg" nil :noerror)
        (org-toggle-inline-images)))))

正規表現の一致が必要かどうかはわかりません。特定のファイル名またはパターンを探していますか?

前者の場合、search-forward代わりに を使用するre-search-forwardと、正規表現構文は必要ありません。

後者の場合、組織モードの「リンク」構文に従って、正規表現を整理する必要があります。

二重角かっこのリンク構文については、これを試すことができます。

(add-hook 'org-mode-hook 'my-org-mode-hook)
(defun my-org-mode-hook ()
  ;; Enable inline images if there are jpeg images in the file.
  (save-excursion
    (save-restriction
      (goto-char (point-min))
      (catch 'done
        (while (re-search-forward org-bracket-link-regexp nil :noerror)
          (when (string-match "^file:.+\\.jpg" (match-string-no-properties 1))
            (org-toggle-inline-images)
            (throw 'done t)))))))

しかし、私は法律家のコメントに同意します-org-startup-with-inline-imagesあなたがカバーしたようです.

于 2013-10-24T03:36:56.057 に答える