Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

example block 内 org-fill-paragraph 无效 #1

Open
et2010 opened this issue Oct 19, 2017 · 1 comment
Open

example block 内 org-fill-paragraph 无效 #1

et2010 opened this issue Oct 19, 2017 · 1 comment
Labels

Comments

@et2010
Copy link

et2010 commented Oct 19, 2017

example block 内 org-fill-paragraph 无效

比如:

#+begin_example
blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah
#+end_example

期待行为:

在 example block 内使用 org-fill-paragraph 应该可以将上面的 block 中的内容 fill:

#+begin_example
blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah 
blah blah blah blah blah blah blah blah blah blah  
#+end_example

实际行为:

什么都没有发生

测试平台:

vanilla emacs 25.3.1 with latest org-plus-contrib

@et2010 et2010 added the bug label Oct 19, 2017
@LeeiFrankJaw
Copy link

下面的内容引用自org-mode的info手册的11.5节。

11.5 Literal examples

You can include literal examples that should not be subjected to markup.
Such examples will be typeset in monospace, so this is well suited for
source code and similar examples.

 #+BEGIN_EXAMPLE
 Some example from a text file.
 #+END_EXAMPLE

Note that such blocks may be indented in order to align nicely with
indented text and in particular with plain list structure (*note Plain
lists::). For simplicity when using small examples, you can also start
the example lines with a colon followed by a space. There may also be
additional whitespace before the colon:

 Here is an example
    : Some example from a text file.

If the example is source code from a programming language, or any
other text that can be marked up by font-lock in Emacs, you can ask for
the example to look like the fontified Emacs buffer(1). This is done
with the ‘src’ block, where you also need to specify the name of the
major mode that should be used to fontify the example(2), see *note Easy
templates:: for shortcuts to easily insert code blocks.

 #+BEGIN_SRC emacs-lisp
   (defun org-xor (a b)
      "Exclusive or."
      (if a (not b) b))
 #+END_SRC

Both in ‘example’ and in ‘src’ snippets, you can add a ‘-n’ switch to
the end of the ‘BEGIN’ line, to get the lines of the example numbered.
The ‘-n’ takes an optional numeric argument specifying the starting line
number of the block. If you use a ‘+n’ switch, the numbering from the
previous numbered snippet will be continued in the current one. The
‘+n’ can also take a numeric argument. The value of the argument will
be added to the last line of the previous block to determine the
starting line number.

 #+BEGIN_SRC emacs-lisp -n 20
  ;; this will export with line number 20
  (message "This is line 21")
 #+END_SRC
 #+BEGIN_SRC emacs-lisp +n 10
  ;; This will be listed as line 31
  (message "This is line 32")
 #+END_SRC

In literal examples, Org will interpret strings like ‘(ref:name)’ as
labels, and use them as targets for special hyperlinks like ‘[[(name)]]’
(i.e., the reference name enclosed in single parenthesis). In HTML,
hovering the mouse over such a link will remote-highlight the
corresponding code line, which is kind of cool.

You can also add a ‘-r’ switch which removes the labels from the
source code(3). With the ‘-n’ switch, links to these references will be
labeled by the line numbers from the code listing, otherwise links will
use the labels with no parentheses. Here is an example:

 #+BEGIN_SRC emacs-lisp -n -r
 (save-excursion                  (ref:sc)
    (goto-char (point-min)))      (ref:jump)
 #+END_SRC
 In line [[(sc)]] we remember the current position.  [[(jump)][Line (jump)]]
 jumps to point-min.

Finally, you can use ‘-i’ to preserve the indentation of a specific
code block (*note Editing source code::).

所以EXAMPLE和SRC片段在处理上是一样,只是EXAMPLE片段没有相关联的模式,而SRC可以有(我记得在版本为8的时候,是必须有)。所以你非得fill-paragraph不可的话,可以这样子。

#+BEGIN_SRC text
  blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah
#+END_SRC

然后在段落里按M-q,就可以得到下面的结果了。

#+BEGIN_SRC text
  blah blah blah blah blah blah blah blah blah blah blah blah blah blah
  blah blah blah blah blah blah blah blah blah blah
#+END_SRC

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants