Function: allout-widgets-post-command-business

allout-widgets-post-command-business is a byte-compiled function defined in allout-widgets.el.gz.

Signature

(allout-widgets-post-command-business &optional RECURSING)

Documentation

Handle actions pending after any allout-mode(var)/allout-mode(fun) commands.

Optional RECURSING is for internal use, to limit recursion.

Source Code

;; Defined in /usr/src/emacs/lisp/allout-widgets.el.gz
;;;_    > allout-widgets-post-command-business (&optional recursing)
(defun allout-widgets-post-command-business (&optional _recursing)
  "Handle actions pending after any `allout-mode' commands.

Optional RECURSING is for internal use, to limit recursion."
  ;; - check changed text for nesting discontinuities and escape anything
  ;;   that's: (1) asterisks at bol or (2) excessively nested.
  (condition-case nil

      (when (and (boundp 'allout-mode) allout-mode)

        (if allout-widgets-unset-inhibit-read-only
            (setq inhibit-read-only nil
                  allout-widgets-unset-inhibit-read-only nil))

        (when allout-widgets-reenable-before-change-handler
          (add-hook 'before-change-functions
                    #'allout-widgets-before-change-handler
                    nil 'local)
          (setq allout-widgets-reenable-before-change-handler nil))

        (when (or allout-widgets-undo-exposure-record
                  allout-widgets-changes-record)
          (let* ((debug-on-signal t)
                 (debug-on-error t)
                 ;; inhibit recording new undo records when processing
                 ;; effects of undo-exposure:
                 (debugger 'allout-widgets-hook-error-handler)
                 (adjusting-message " Adjusting widgets...")
                 (replaced-message (allout-widgets-adjusting-message
                                    adjusting-message))
                 (start-time (current-time)))

            (if allout-widgets-undo-exposure-record
                ;; inhibit undo recording iff undoing exposure stuff.
                ;; XXX we might need to inhibit per respective
                ;;     change-record, rather than assuming that some undo
                ;;     activity during a command is all undo activity.
                (let ((buffer-undo-list t))
                  (allout-widgets-exposure-undo-processor)
                  (allout-widgets-changes-dispatcher))
              (allout-widgets-exposure-undo-processor)
              (allout-widgets-changes-dispatcher))

            (if allout-widgets-time-decoration-activity
                (setq allout-widgets-last-decoration-timing
                      (list (allout-elapsed-time-seconds nil start-time)
                            allout-widgets-changes-record)))

            (setq allout-widgets-changes-record nil)

            (if replaced-message
                (if (stringp replaced-message)
                    (message replaced-message)
                  (message "")))))

        ;; alas, decorated intermediate matches are not easily undecorated
        ;; when they're automatically rehidden by isearch, so we're
        ;; dropping this nicety.
        ;; ;; Detect undecorated items, eg during isearch into previously
        ;; ;; unexposed topics, and decorate "economically".  Some
        ;; ;; undecorated stuff is often exposed, to reduce lag, but the
        ;; ;; item containing the cursor is decorated.  We constrain
        ;; ;; recursion to avoid being trapped by unexpectedly undecoratable
        ;; ;; items.
        ;; (when (and (not recursing)
        ;;            (not (allout-current-decorated-p))
        ;;            (or (not (equal (allout-depth) 0))
        ;;                (not allout-container-item-widget)))
        ;;   (let ((buffer-undo-list t))
        ;;     (allout-widgets-exposure-change-recorder
        ;;      allout-recent-prefix-beginning allout-recent-prefix-end nil)
        ;;     (allout-widgets-post-command-business 'recursing)))

        ;; Detect and rectify fouled outline structure - decorated item
        ;; not at beginning of line.
        (let ((this-widget (or (widget-at (point))
                               ;; XXX we really should be checking across
                               ;; edited span, not just point and point+1
                               (and (not (eq (point) (point-max)))
                                    (widget-at (1+ (point))))))
              inserted-at)
          (save-excursion
            (if (and this-widget
                     (goto-char (widget-get this-widget :from))
                     (not (bolp)))
                (if (not
                     (condition-case nil
                         (yes-or-no-p
                          (concat "Misplaced item won't be recognizable "
                                  " as part of outline - rectify? "))
                       (quit nil)))
                    (progn
                      (if (allout-hidden-p (max (1- (point)) 1))
                          (save-excursion
                            (goto-char (max (1- (point)) 1))
                            (allout-show-to-offshoot)))
                      (allout-widgets-undecorate-item this-widget))
                  ;; expose any hidden intervening items, so resulting
                  ;; position is clear:
                  (setq inserted-at (point))
                  (allout-unprotected (insert-before-markers "\n"))
                  (forward-char -1)
                  ;; ensure the inserted newline is visible:
                  (allout-flag-region inserted-at (1+ inserted-at) nil)
                  (allout-widgets-post-command-business 'recursing)
                  (message (concat "outline structure corrected - item"
                                   " moved to beginning of new line"))
                  ;; preserve cursor position in some cases:
                  (if (and inserted-at
                           (> (point) inserted-at))
                      (forward-char -1)))))))

    (error
     ;; zero work list so we don't get stuck futilely retrying.
     ;; error recording done by allout-widgets-hook-error-handler.
     (setq allout-widgets-changes-record nil))))