Frage

Ich verwende M-q für Fill-Absatz, kann ich den un-Fill-Absatz in Auto-Fill-Modus tun?

Mit org-Modus, gebe ich manchmal [[Sehr langen HTML] [Namen mit Leerzeichen]] , und für den 'Namen mit Leerzeichen' dem Auto-Fill-Modus bricht die ganze Linie auf der Basis eingeführt Raum, die es sehr hässlich macht.

Gibt es einen Befehl so etwas wie un-fill-paragraph? Oder ist es eine Möglichkeit, deaktivieren Sie Auto-Fill-Modus vorübergehend / lokal?

War es hilfreich?

Lösung

Emacs zeichnet nicht, was Ihre Linie war vor fill-paragraph Aufruf. Das einzige, was Sie tun können, ist C -_ , die den Befehl rückgängig läuft. Es kann Ihren fill-paragraph Befehl aber nur, wenn es der vorhergehenden Befehl Aufruf.

rückgängig machen

Wenn Sie auf einer Zeile einen mehrzeiligen Absatz setzen wollen Sie wie dies tun könnten:

  • Wählen Sie die Region
  • CM -% Cq Cj RET SPACE RET

Andere Tipps

Xah Lee hat seinen Code seit monotux Antwort aktualisiert, und ich Refactoring es etwas zur besseren Lesbarkeit:

(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)))))

Um eine lange Schlange aus einem Absatz in Org-Modus Remake, gab ich mir einen neuen Befehl. Hier ist der zugehörige Emacs Lisp-Code:

(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)

Natürlich passen Sie den Befehl Keybinding wie Sie sehen, passen!

ich das folgende Snippet zu füllen und un-fill Absätze (mit nur M-q), es ist wirklich, wirklich praktisch. Ich lieh es aus Xah Lee, aber entfernt einige Kommentare und Leerzeichen, um es in hier fit zu machen. Der Link in dem ersten Kommentar geht zu seinem ursprünglichen Code.

;; 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)
Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top