段落の埋め込みに MQ を使用していますが、自動埋め込みモードで段落の埋め込みを解除できますか?
組織モードでは[[非常に長い HTML][スペースを含む名前]]と入力することがあり、「スペースを含む名前」の場合、自動入力モードは挿入されたスペースに基づいて行全体を分割するため、非常に見苦しくなります。
un-fill-paragraph のようなコマンドはありますか? または、auto-fill-mode を一時的/ローカルに無効にする方法はありますか?
Emacs は、 を呼び出す前の行を記録しませんfill-paragraph
。したがって、実行できる唯一のことはC-_、コマンド undo を実行することです。コマンドを元に戻すことができますfill-paragraph
が、それが前のコマンド呼び出しである場合に限ります。
1 行に複数行の段落を入れたい場合は、次のようにできます。
Xah Leeは、monotuxの回答以来、コードを更新しており、読みやすくするためにコードをリファクタリングしました。
(defun my-toggle-fill-paragraph ()
;; Based on http://xahlee.org/emacs/modernization_fill-paragraph.html
"Fill or unfill the current paragraph, depending upon the current line length.
When there is a text selection, act on the region.
See `fill-paragraph' and `fill-region'."
(interactive)
;; We set a property 'currently-filled-p on this command's symbol
;; (i.e. on 'my-toggle-fill-paragraph), thus avoiding the need to
;; create a variable for remembering the current fill state.
(save-excursion
(let* ((deactivate-mark nil)
(line-length (- (line-end-position) (line-beginning-position)))
(currently-filled (if (eq last-command this-command)
(get this-command 'currently-filled-p)
(< line-length fill-column)))
(fill-column (if currently-filled
most-positive-fixnum
fill-column)))
(if (region-active-p)
(fill-region (region-beginning) (region-end))
(fill-paragraph))
(put this-command 'currently-filled-p (not currently-filled)))))
Org モードで段落から長い行を作り直すために、私は自分自身に新しいコマンドを与えました。関連する Emacs Lisp コードは次のとおりです。
(defun fp-unfill-paragraph (&optional justify region)
(interactive (progn
(barf-if-buffer-read-only)
(list (if current-prefix-arg 'full) t)))
(interactive)
(let ((fill-column 100000))
(fill-paragraph justify region)))
(global-set-key "\C-ceu" 'fp-unfill-paragraph)
もちろん、必要に応じてコマンドのキーバインドを調整してください!
次のスニペットを使用して、段落を塗りつぶしたり、塗りつぶしたりしません(のみを使用M-q
)。これは本当に便利です。Xah Leeから借りましたが、ここに収まるようにコメントと空白を削除しました。最初のコメントのリンクは彼の元のコードに行きます。
;; http://xahlee.org/emacs/modernization_fill-paragraph.html
(defun compact-uncompact-block ()
"Remove or add line endings on the current block of text.
This is similar to a toggle for fill-paragraph and unfill-paragraph
When there is a text selection, act on the region.
When in text mode, a paragraph is considered a block. When in programing
language mode, the block defined by between empty lines.
Todo: The programing language behavior is currently not done.
Right now, the code uses fill* functions, so does not work or work well
in programing lang modes. A proper implementation to compact is replacing
newline chars by space when the newline char is not inside string.
"
(interactive)
(let (bds currentLineCharCount currentStateIsCompact
(bigFillColumnVal 4333999) (deactivate-mark nil))
(save-excursion
(setq currentLineCharCount
(progn
(setq bds (bounds-of-thing-at-point 'line))
(length (buffer-substring-no-properties (car bds) (cdr bds)))))
(setq currentStateIsCompact
(if (eq last-command this-command)
(get this-command 'stateIsCompact-p)
(if (> currentLineCharCount fill-column) t nil)))
(if (and transient-mark-mode mark-active)
(if currentStateIsCompact
(fill-region (region-beginning) (region-end))
(let ((fill-column bigFillColumnVal))
(fill-region (region-beginning) (region-end)))
)
(if currentStateIsCompact
(fill-paragraph nil)
(let ((fill-column bigFillColumnVal))
(fill-paragraph nil))))
(put this-command 'stateIsCompact-p
(if currentStateIsCompact
nil t)))))
(global-set-key (kbd "M-q") 'compact-uncompact-block)