Function: rst-adjust

rst-adjust is an interactive and byte-compiled function defined in rst.el.gz.

Signature

(rst-adjust PFXARG)

Documentation

Auto-adjust the adornment around point.

Adjust/rotate the section adornment for the section title around point or promote/demote the adornments inside the region, depending on whether the region is active. This function is meant to be invoked possibly multiple times, and can vary its behavior with a positive PFXARG (toggle style), or with a negative PFXARG (alternate behavior).

This function is a bit of a swiss knife. It is meant to adjust the adornments of a section title in reStructuredText. It tries to deal with all the possible cases gracefully and to do "the right thing" in all cases.

See the documentations of rst-adjust-section and rst-adjust-region for full details.

The method can take either (but not both) of

a. a (non-negative) prefix argument, which means to toggle the
   adornment style. Invoke with a prefix argument for example;

b. a negative numerical argument, which generally inverts the
   direction of search in the file or hierarchy. Invoke with C--
   prefix for example.

Probably introduced at or before Emacs version 24.3.

Key Bindings

Aliases

rst-adjust-section-title (obsolete since 29.1)

Source Code

;; Defined in /usr/src/emacs/lisp/textmodes/rst.el.gz
;; FIXME: A line "``/`` full" is not accepted as a section title.
(defun rst-adjust (pfxarg)
  ;; testcover: ok.
  "Auto-adjust the adornment around point.
Adjust/rotate the section adornment for the section title around
point or promote/demote the adornments inside the region,
depending on whether the region is active.  This function is meant
to be invoked possibly multiple times, and can vary its behavior
with a positive PFXARG (toggle style), or with a negative
PFXARG (alternate behavior).

This function is a bit of a swiss knife.  It is meant to adjust
the adornments of a section title in reStructuredText.  It tries
to deal with all the possible cases gracefully and to do \"the
right thing\" in all cases.

See the documentations of `rst-adjust-section' and
`rst-adjust-region' for full details.

The method can take either (but not both) of

a. a (non-negative) prefix argument, which means to toggle the
   adornment style.  Invoke with a prefix argument for example;

b. a negative numerical argument, which generally inverts the
   direction of search in the file or hierarchy.  Invoke with C--
   prefix for example."
  (interactive "P")
  (let* ((origpt (point-marker))
         (reverse-direction (and pfxarg (< (prefix-numeric-value pfxarg) 0)))
         (toggle-style (and pfxarg (not reverse-direction))))
    (if (use-region-p)
        (rst-adjust-region (and pfxarg t))
      (let ((msg (rst-adjust-section toggle-style reverse-direction)))
	(when msg
	  (apply #'message msg))))
    (run-hooks 'rst-adjust-hook)
    (rst-reset-section-caches)
    (set-marker
     (goto-char origpt) nil)))