Pregunta

Yo uso M-Q para el relleno párrafo, puedo hacer que la ONU-llenado-párrafo de auto-fill-mode?

Con el modo org, a veces entrar en [[Muy largo HTML] [Nombre con espacios]] , y para el 'Nombre con espacios' el modo de auto-llenado romper la línea de conjunto, basada en el insertado espacio, lo que hace que sea muy feo.

¿Hay un comando de algo así como un-llenado apartado? O, ¿hay un bloqueo de auto-fill-mode manera temporal / local?

¿Fue útil?

Solución

Emacs no registra lo que era su línea antes de llamar fill-paragraph. Así que lo único que puede hacer es C -_ que ejecuta el comando deshacer. Se puede deshacer el comando fill-paragraph pero sólo si es el llamado comando anterior.

Si usted quiere poner un párrafo de varias líneas en una línea que podría hacer de esta manera:

  • Seleccione la región
  • CM -% Cq Cj RET SPACE RET

Otros consejos

Xah Lee ha actualizado su código desde la respuesta de monotux, y yo refactorizado un tanto para facilitar la lectura:

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

Para rehacer una larga línea de un párrafo en el modo Org, me di a un nuevo comando. Aquí está el código Emacs Lisp asociado:

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

Por supuesto, ajustar la combinación de teclas de comando como mejor le parezca!

Yo uso el siguiente fragmento de llenar y párrafos no-Fill (usando sólo M-q), es muy, muy práctico. Tomé prestado de Xah Lee, pero quitado algunos comentarios y espacios con el fin de que se ajuste aquí. El enlace en el primer comentario va a su código original.

;; 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)
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top