avoid recursive `require' when loading semantic
[bpt/emacs.git] / lisp / allout-widgets.el
index ef75e71..66ec0c3 100644 (file)
@@ -1,14 +1,28 @@
 ;; allout-widgets.el --- Visually highlight allout outline structure.
 
-;; Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2011 Ken Manheimer
+;; Copyright (C) 2005-2014 Free Software Foundation, Inc.
 
-;; Author: Ken Manheimer <ken dot manheimer at gmail dot com>
-;; Maintainer: Ken Manheimer <ken dot manheimer at gmail dot com>
+;; Author: Ken Manheimer <ken dot manheimer at gmail...>
+;; Maintainer: Ken Manheimer <ken dot manheimer at gmail...>
 ;; Version: 1.0
 ;; Created: Dec 2005
-;; Version: 1.0
 ;; Keywords: outlines
-;; Website: http://myriadicity.net/Sundry/EmacsAllout
+;; Website: http://myriadicity.net/software-and-systems/craft/emacs-allout
+
+;; This file is part of GNU Emacs.
+
+;; GNU Emacs is free software: you can redistribute it and/or modify
+;; it under the terms of the GNU General Public License as published by
+;; the Free Software Foundation, either version 3 of the License, or
+;; (at your option) any later version.
+
+;; GNU Emacs is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+;; GNU General Public License for more details.
+
+;; You should have received a copy of the GNU General Public License
+;; along with GNU Emacs.  If not, see <http://www.gnu.org/licenses/>.
 
 ;;; Commentary:
 
@@ -50,7 +64,7 @@
 ;; systematically couple overlays, graphics, and other features with
 ;; allout-governed text.
 
-;;;_: Code (structured with comments that delinieate an allout outline)
+;;; Code:
 
 ;;;_ : General Environment
 (require 'allout)
@@ -76,7 +90,6 @@
 
 ;;;_ : USER CUSTOMIZATION VARIABLES and incidental functions:
 ;;;_  > defgroup allout-widgets
-;;;###autoload
 (defgroup allout-widgets nil
   "Allout extension that highlights outline structure graphically.
 
@@ -109,7 +122,7 @@ inhibition of allout-widgets-mode."
 ;;;_  > allout-widgets-setup (varname value)
 ;;;###autoload
 (defun allout-widgets-setup (varname value)
-  "Commission or decommision allout-widgets-mode along with allout-mode.
+  "Commission or decommission allout-widgets-mode along with allout-mode.
 
 Meant to be used by customization of `allout-widgets-auto-activation'."
   (set-default varname value)
@@ -132,13 +145,14 @@ explicitly invoke `allout-widgets-mode' in allout buffers where
 you want allout widgets operation.
 
 See `allout-widgets-mode' for allout widgets mode features."
+  :version "24.1"
   :type 'boolean
   :group 'allout-widgets
   :set 'allout-widgets-setup
  )
 ;; ;;;_  = allout-widgets-allow-unruly-edits
 ;; (defcustom allout-widgets-allow-unruly-edits nil
-;;   "*Control whether manual edits are restricted to maintain outline integrity.
+;;   "Control whether manual edits are restricted to maintain outline integrity.
 
 ;; When nil, manual edits must either be within an item's body or encompass
 ;; one or more items completely - eg, killing topics as entities, rather than
@@ -156,16 +170,19 @@ See `allout-widgets-mode' for allout widgets mode features."
 ;;;_  = allout-widgets-icons-dark-subdir
 (defcustom allout-widgets-icons-dark-subdir "icons/allout-widgets/dark-bg/"
   "Directory on `image-load-path' holding allout icons for dark backgrounds."
+  :version "24.1"
   :type 'string
   :group 'allout-widgets)
 ;;;_  = allout-widgets-icons-light-subdir
 (defcustom allout-widgets-icons-light-subdir "icons/allout-widgets/light-bg/"
   "Directory on `image-load-path' holding allout icons for light backgrounds."
+  :version "24.1"
   :type 'string
   :group 'allout-widgets)
 ;;;_  = allout-widgets-icon-types
 (defcustom allout-widgets-icon-types '(xpm png)
   "File extensions for the icon graphic format types, in order of preference."
+  :version "24.1"
   :type '(repeat symbol)
   :group 'allout-widgets)
 
@@ -173,29 +190,33 @@ See `allout-widgets-mode' for allout widgets mode features."
 ;;;_   = allout-widgets-theme-dark-background
 (defcustom allout-widgets-theme-dark-background "allout-dark-bg"
   "Identify the outline's icon theme to use with a dark background."
+  :version "24.1"
   :type '(string)
   :group 'allout-widgets)
 ;;;_   = allout-widgets-theme-light-background
 (defcustom allout-widgets-theme-light-background "allout-light-bg"
   "Identify the outline's icon theme to use with a light background."
+  :version "24.1"
   :type '(string)
   :group 'allout-widgets)
 ;;;_   = allout-widgets-item-image-properties-emacs
 (defcustom allout-widgets-item-image-properties-emacs
   '(:ascent center :mask (heuristic t))
-  "*Default properties item widget images in mainline Emacs."
+  "Default properties item widget images in mainline Emacs."
+  :version "24.1"
   :type 'plist
   :group 'allout-widgets)
 ;;;_   = allout-widgets-item-image-properties-xemacs
 (defcustom allout-widgets-item-image-properties-xemacs
   nil
-  "*Default properties item widget images in XEmacs."
+  "Default properties item widget images in XEmacs."
+  :version "24.1"
   :type 'plist
   :group 'allout-widgets)
 ;;;_  . Developer
 ;;;_   = allout-widgets-run-unit-tests-on-load
 (defcustom allout-widgets-run-unit-tests-on-load nil
-  "*When non-nil, unit tests will be run at end of loading allout-widgets.
+  "When non-nil, unit tests will be run at end of loading allout-widgets.
 
 Generally, allout widgets code developers are the only ones who'll want to
 set this.
@@ -205,43 +226,47 @@ doing byte-compilation with a repeat count, so the file is loaded after
 compilation.)
 
 See `allout-widgets-run-unit-tests' to see what's run."
+  :version "24.1"
   :type 'boolean
   :group 'allout-widgets-developer)
 ;;;_   = allout-widgets-time-decoration-activity
 (defcustom allout-widgets-time-decoration-activity nil
-  "*Retain timing info of the last cooperative redecoration.
+  "Retain timing info of the last cooperative redecoration.
 
 The details are retained as the value of
 `allout-widgets-last-decoration-timing'.
 
 Generally, allout widgets code developers are the only ones who'll want to
 set this."
+  :version "24.1"
   :type 'boolean
   :group 'allout-widgets-developer)
 ;;;_   = allout-widgets-hook-error-post-time 0
 (defcustom allout-widgets-hook-error-post-time 0
-  "*Amount of time to sit showing hook error messages.
+  "Amount of time to sit showing hook error messages.
 
 0 is minimal, or nil to not post to the message area.
 
 This is for debugging purposes."
+  :version "24.1"
   :type 'integer
   :group 'allout-widgets-developer)
 ;;;_   = allout-widgets-maintain-tally nil
 (defcustom allout-widgets-maintain-tally nil
-  "*If non-nil, maintain a collection of widgets, `allout-widgets-tally'.
+  "If non-nil, maintain a collection of widgets, `allout-widgets-tally'.
 
 This is for debugging purposes.
 
 The tally shows the total number of item widgets in the current
 buffer, and tracking increases as new widgets are added and
 decreases as obsolete widgets are garbage collected."
+  :version "24.1"
   :type 'boolean
   :group 'allout-widgets-developer)
 (defvar allout-widgets-tally nil
   "Hash-table of existing allout widgets, for debugging.
 
-Table is maintained iff `allout-widgets-maintain-tally' is non-nil.
+Table is maintained only if `allout-widgets-maintain-tally' is non-nil.
 
 The table contents will be out of sync if any widgets are created
 or deleted while this variable is nil.")
@@ -264,11 +289,12 @@ The number varies according to the evanescence of objects on a
     (format ":%s" (hash-table-count allout-widgets-tally))))
 ;;;_   = allout-widgets-track-decoration nil
 (defcustom allout-widgets-track-decoration nil
-  "*If non-nil, show cursor position of each item decoration.
+  "If non-nil, show cursor position of each item decoration.
 
 This is for debugging purposes, and generally set at need in a
-buffer rather than as a prevailing configuration \(but it's handy
-to publicize it by making it a customization variable\)."
+buffer rather than as a prevailing configuration (but it's handy
+to publicize it by making it a customization variable)."
+  :version "24.1"
   :type 'boolean
   :group 'allout-widgets-developer)
 (make-variable-buffer-local 'allout-widgets-track-decoration)
@@ -319,7 +345,7 @@ to `allout-body-modification-handler', and is always reset by
   "Cache allout icon images, as an association list.
 
 `allout-fetch-icon-image' uses this cache transparently, keying
-images with lists containing the name of the icon directory \(as
+images with lists containing the name of the icon directory (as
 found on the `load-path') and the icon name.
 
 Set this variable to `nil' to empty the cache, and have it replenish from the
@@ -389,7 +415,7 @@ onto the front.")
 ;;;_   , Widget-specific outline text format
 ;;;_    = allout-escaped-prefix-regexp
 (defvar allout-escaped-prefix-regexp ""
-  "*Regular expression for body text that would look like an item prefix if
+  "Regular expression for body text that would look like an item prefix if
 not altered with an escape sequence.")
 (make-variable-buffer-local 'allout-escaped-prefix-regexp)
 ;;;_   , Widget element formatting
@@ -458,7 +484,7 @@ including things like:
  - encryption '~'
  - numbering '#'
  - indirect reference '@'
- - distinctive bullets - see `allout-distinctive-bullets-string'.\)")
+ - distinctive bullets - see `allout-distinctive-bullets-string'.)")
 ;;;_    = allout-span-to-category
 (defvar allout-span-to-category
   '((:guides-span . allout-guides-span-category)
@@ -486,13 +512,14 @@ happens in the buffer.")
 ;;;_   > define-minor-mode allout-widgets-mode (arg)
 ;;;###autoload
 (define-minor-mode allout-widgets-mode
-  "Allout-mode extension, providing graphical decoration of outline structure.
+  "Toggle Allout Widgets mode.
+With a prefix argument ARG, enable Allout Widgets mode if ARG is
+positive, and disable it otherwise.  If called from Lisp, enable
+the mode if ARG is omitted or nil.
 
-This is meant to operate along with allout-mode, via `allout-mode-hook'.
-
-If optional argument ARG is greater than 0, enable.
-If optional argument ARG is less than 0, disable.
-Anything else, toggle between active and inactive.
+Allout Widgets mode is an extension of Allout mode that provides
+graphical decoration of outline structure.  It is meant to
+operate along with `allout-mode', via `allout-mode-hook'.
 
 The graphics include:
 
@@ -506,7 +533,7 @@ The graphics include:
 
 The bullet-icon and guide line graphics provide keybindings and mouse
 bindings for easy outline navigation and exposure control, extending
-outline hot-spot navigation \(see `allout-mode')."
+outline hot-spot navigation (see `allout-mode')."
 
   :lighter nil
   :keymap nil
@@ -551,13 +578,13 @@ outline hot-spot navigation \(see `allout-mode')."
         (if (current-local-map)
             (set-keymap-parent allout-item-body-keymap (current-local-map)))
 
-        (add-hook 'allout-exposure-change-hook
+        (add-hook 'allout-exposure-change-functions
                   'allout-widgets-exposure-change-recorder nil 'local)
-        (add-hook 'allout-structure-added-hook
+        (add-hook 'allout-structure-added-functions
                   'allout-widgets-additions-recorder nil 'local)
-        (add-hook 'allout-structure-deleted-hook
+        (add-hook 'allout-structure-deleted-functions
                   'allout-widgets-deletions-recorder nil 'local)
-        (add-hook 'allout-structure-shifted-hook
+        (add-hook 'allout-structure-shifted-functions
                   'allout-widgets-shifts-recorder nil 'local)
         (add-hook 'allout-after-copy-or-kill-hook
                   'allout-widgets-after-copy-or-kill-function nil 'local)
@@ -598,13 +625,13 @@ outline hot-spot navigation \(see `allout-mode')."
 
       (remove-hook 'after-change-functions
                    'allout-widgets-after-change-handler 'local)
-      (remove-hook 'allout-exposure-change-hook
+      (remove-hook 'allout-exposure-change-functions
                    'allout-widgets-exposure-change-recorder 'local)
-      (remove-hook 'allout-structure-added-hook
+      (remove-hook 'allout-structure-added-functions
                    'allout-widgets-additions-recorder 'local)
-      (remove-hook 'allout-structure-deleted-hook
+      (remove-hook 'allout-structure-deleted-functions
                    'allout-widgets-deletions-recorder 'local)
-      (remove-hook 'allout-structure-shifted-hook
+      (remove-hook 'allout-structure-shifted-functions
                    'allout-widgets-shifts-recorder 'local)
       (remove-hook 'allout-after-copy-or-kill-hook
                    'allout-widgets-after-copy-or-kill-function 'local)
@@ -618,11 +645,11 @@ outline hot-spot navigation \(see `allout-mode')."
       (set-buffer-modified-p was-modified))))
 ;;;_   > allout-widgets-mode-off
 (defun allout-widgets-mode-off ()
-  "Explicitly disable allout-widgets-mode."
+  "Explicitly disable `allout-widgets-mode'."
   (allout-widgets-mode -1))
 ;;;_   > allout-widgets-mode-off
 (defun allout-widgets-mode-on ()
-  "Explicitly disable allout-widgets-mode."
+  "Explicitly enable `allout-widgets-mode'."
   (allout-widgets-mode 1))
 ;;;_   > allout-setup-text-properties ()
 (defun allout-setup-text-properties ()
@@ -686,23 +713,23 @@ outline hot-spot navigation \(see `allout-mode')."
 (defvar allout-container-item-widget nil
   "A widget for the current outline's overarching container as an item.
 
-The item has settings \(of the file/connection\) and maybe a body, but no
+The item has settings (of the file/connection) and maybe a body, but no
 icon/bullet.")
 (make-variable-buffer-local 'allout-container-item-widget)
 ;;;_  . Hooks and hook helpers
 ;;;_   , major command-loop business:
 ;;;_    > allout-widgets-pre-command-business (&optional recursing)
-(defun allout-widgets-pre-command-business (&optional recursing)
-  "Handle actions pending before allout-mode activity."
+(defun allout-widgets-pre-command-business (&optional _recursing)
+  "Handle actions pending before `allout-mode' activity."
 )
 ;;;_    > allout-widgets-post-command-business (&optional recursing)
-(defun allout-widgets-post-command-business (&optional recursing)
-  "Handle actions pending after any allout-mode commands.
+(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 failure
+  (condition-case nil
 
       (when (and (boundp 'allout-mode) allout-mode)
 
@@ -783,7 +810,7 @@ Optional RECURSING is for internal use, to limit recursion."
                      (goto-char (widget-get this-widget :from))
                      (not (bolp)))
                 (if (not
-                     (condition-case err
+                     (condition-case nil
                          (yes-or-no-p
                           (concat "Misplaced item won't be recognizable "
                                   " as part of outline - rectify? "))
@@ -810,7 +837,7 @@ Optional RECURSING is for internal use, to limit recursion."
                       (forward-char -1)))))))
 
     (error
-     ;; zero work list so we don't get stuck futily retrying.
+     ;; 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))))
 ;;;_   , major change handlers:
@@ -845,7 +872,7 @@ Optional RECURSING is for internal use, to limit recursion."
     (error
      (substitute-command-keys allout-structure-unruly-deletion-message)))))
 ;;;_    > allout-widgets-after-change-handler
-(defun allout-widgets-after-change-handler (beg end prelength)
+(defun allout-widgets-after-change-handler (_beg _end _prelength)
   "Reconcile what needs to be reconciled for allout widgets after edits."
   )
 ;;;_   > allout-current-decorated-p ()
@@ -964,14 +991,13 @@ Records changes in `allout-widgets-changes-record'."
 (defun allout-widgets-exposure-change-processor (changes)
   "Widgetize and adjust item widgets tracking allout outline exposure changes.
 
-Generally invoked via `allout-exposure-change-hook'."
+Generally invoked via `allout-exposure-change-functions'."
 
   (let ((changes (sort changes (function (lambda (this next)
                                            (< (cadr this) (cadr next))))))
         ;; have to distinguish between concealing and exposing so that, eg,
         ;; `allout-expose-topic's mix is handled properly.
         handled-expose
-        handled-conceal
         covered
         deactivate-mark)
 
@@ -1031,7 +1057,7 @@ Generally invoked via `allout-exposure-change-hook'."
 (defun allout-widgets-additions-recorder (from to)
   "Record allout item additions for tracking during post-command processing.
 
-Intended for use on `allout-structure-added-hook'.
+Intended for use on `allout-structure-added-functions'.
 
 FROM point at the start of the first new item and TO is point at the start
 of the last one.
@@ -1078,8 +1104,7 @@ Dispatched by `allout-widgets-post-command-business' in response to
 ;;;_   > allout-widgets-deletions-recorder (depth from)
 (defun allout-widgets-deletions-recorder (depth from)
   "Record allout item deletions for tracking during post-command processing.
-
-Intended for use on `allout-structure-deleted-hook'.
+Intended for use on `allout-structure-deleted-functions'.
 
 DEPTH is the depth of the deleted subtree, and FROM is the point from which
 the subtree was deleted.
@@ -1106,8 +1131,7 @@ Dispatched by `allout-widgets-post-command-business' in response to
 ;;;_   > allout-widgets-shifts-recorder (shifted-amount at)
 (defun allout-widgets-shifts-recorder (shifted-amount at)
   "Record outline subtree shifts for tracking during post-command processing.
-
-Intended for use on `allout-structure-shifted-hook'.
+Intended for use on `allout-structure-shifted-functions'.
 
 SHIFTED-AMOUNT is the depth change and AT is the point at the start of the
 subtree that's been shifted.
@@ -1129,14 +1153,14 @@ Dispatched by `allout-widgets-post-command-business' in response to
 (defun allout-widgets-after-copy-or-kill-function ()
   "Do allout-widgets processing of text just placed in the kill ring.
 
-Intended for use on allout-after-copy-or-kill-hook."
+Intended for use on `allout-after-copy-or-kill-hook'."
   (if (car kill-ring)
       (setcar kill-ring (allout-widgets-undecorate-text (car kill-ring)))))
 ;;;_   > allout-widgets-after-undo-function ()
 (defun allout-widgets-after-undo-function ()
   "Do allout-widgets processing of text after an undo.
 
-Intended for use on allout-post-undo-hook."
+Intended for use on `allout-post-undo-hook'."
   (save-excursion
     (if (allout-goto-prefix)
         (allout-redecorate-item (allout-get-or-create-item-widget)))))
@@ -1162,7 +1186,7 @@ Dispatched by `allout-widgets-post-command-business' in response to
   (let* ((allout-undo-exposure-in-progress t)
          ;; inhibit undo recording while twiddling exposure to track undo:
          (widgets allout-widgets-undo-exposure-record)
-         widget widget-start-marker widget-end-marker
+         widget-start-marker widget-end-marker
          from-state icon-start-point to-state
          handled covered)
     (setq allout-widgets-undo-exposure-record nil)
@@ -1244,7 +1268,7 @@ Optional FROM-DEPTH is for internal use."
 (defun allout-range-overlaps (from to ranges)
   "Return a pair indicating overlap of FROM and TO subtree range in RANGES.
 
-First element of result indicates whether candadate range FROM, TO
+First element of result indicates whether candidate range FROM, TO
 overlapped any of the existing ranges.
 
 Second element of result is a new version of RANGES incorporating the
@@ -1333,7 +1357,7 @@ FROM and TO must be in increasing order, as must be the pairs in RANGES."
     (list (if included-from t) new-ranges)))
 ;;;_   > allout-test-range-overlaps ()
 (defun allout-test-range-overlaps ()
-  "allout-range-overlaps unit tests."
+  "`allout-range-overlaps' unit tests."
   (let* (ranges
          got
          (try (lambda (from to)
@@ -1348,7 +1372,6 @@ FROM and TO must be in increasing order, as must be the pairs in RANGES."
 ;;              (time-trial
 ;;               '(let ((size 10000)
 ;;                      doing)
-;;                  (random t)
 ;;                  (dotimes (count size)
 ;;                    (setq doing (random size))
 ;;                    (funcall try doing (+ doing (random 5)))
@@ -1464,7 +1487,7 @@ recursive operation."
 
   :from           nil                   ; item beginning - marker
   :to             nil                   ; item end - marker
-  :span-overlay   nil   ; overlay by which actual postion is determined
+  :span-overlay   nil   ; overlay by which actual position is determined
 
   ;; also serves as guide-end:
   :icon-start     nil
@@ -1527,12 +1550,12 @@ recursive operation."
 ;;;_   > allout-decorate-item-and-context (item-widget &optional redecorate
 ;;;                                                   blank-container parent)
 (defun allout-decorate-item-and-context (item-widget &optional redecorate
-                                                     blank-container parent)
+                                                     blank-container _parent)
   "Create or adjust widget decorations for ITEM-WIDGET and neighbors at point.
 
 The neighbors include its siblings and parent.
 
-ITEM-WIDGET can be a created or converted allout-item-widget.
+ITEM-WIDGET can be a created or converted `allout-item-widget'.
 
 If you're only trying to get or create a widget for an item, use
 `allout-get-or-create-item-widget'.  If you have the item-widget, applying
@@ -1540,7 +1563,7 @@ If you're only trying to get or create a widget for an item, use
 
 Optional BLANK-CONTAINER is for internal use.  It is used to fabricate a
 container widget for an empty-bodied container, in the course of decorating
-a proper \(non-container\) item which starts at the beginning of the file.
+a proper (non-container) item which starts at the beginning of the file.
 
 Optional REDECORATE causes redecoration of the item-widget and
 its siblings, even if already decorated in this cycle of the command loop.
@@ -1568,12 +1591,8 @@ We return the item-widget corresponding to the item at point."
                                 steady-point))
            (parent (and (not is-container)
                         (allout-get-or-create-parent-widget)))
-           parent-flags parent-depth
            successor-sibling
-           body
            doing-item
-           sub-item-widget
-           depth
            reverse-siblings-chart
            (buffer-undo-list t))
 
@@ -1590,7 +1609,6 @@ We return the item-widget corresponding to the item at point."
             ;; `allout-goto-prefix' will go to first non-container item:
             (allout-goto-prefix)
           (allout-next-heading))
-        (setq depth (allout-recent-depth))
         (setq reverse-siblings-chart (list allout-recent-prefix-beginning))
         (while (allout-next-sibling)
           (push allout-recent-prefix-beginning reverse-siblings-chart)))
@@ -1623,7 +1641,7 @@ We return the item-widget corresponding to the item at point."
 
       (set-buffer-modified-p was-modified)
       (goto-char steady-point)
-      ;; must null the marker or the buffer gets clogged with impedence:
+      ;; must null the marker or the buffer gets clogged with impedance:
       (set-marker steady-point nil)
 
       item-widget)))
@@ -1631,11 +1649,11 @@ We return the item-widget corresponding to the item at point."
 (defun allout-redecorate-item (item-widget)
   "Resituate ITEM-WIDGET decorations, disregarding context.
 
-Use this to redecorate only the item, when you know that it's
+Use this to redecorate only the item, when you know that its
 situation with respect to siblings, parent, and offspring is
 unchanged from its last decoration.  Use
 `allout-decorate-item-and-context' instead to reassess and adjust
-relevent context, when suitable."
+relevant context, when suitable."
   (if (not (equal (widget-get item-widget :last-decorated-tick)
                   allout-command-counter))
       (let ((was-modified (buffer-modified-p))
@@ -1677,7 +1695,6 @@ Point is left at the last sibling in the visible subtree."
         (pending-chart (or chart (allout-chart-subtree nil 'visible)))
         item-widget
         previous-sibling-point
-        previous-sibling
         recent-sibling-point)
     (setq pending-chart (nreverse pending-chart))
     (dolist (sibling-point pending-chart)
@@ -1712,8 +1729,8 @@ If optional AT-BEGINNING is t, then point is assumed to be at the start of
 the item prefix.
 
 If optional BLANK-CONTAINER is true, then the parameters of a container
-which has an empty body are set.  \(Though the body is blank, the object
-may have subitems.\)"
+which has an empty body are set.  (Though the body is blank, the object
+may have subitems.)"
 
   ;; Uncomment this sit-for to notice where decoration is happening:
 ;;  (sit-for .1)
@@ -1728,9 +1745,7 @@ may have subitems.\)"
          (icon-start (1- icon-end))
          body-start
          body-end
-         bullet
          has-subitems
-         (contents-depth (1+ depth))
          )
     (widget-put item-widget :depth depth)
     (if is-container
@@ -1758,7 +1773,7 @@ may have subitems.\)"
 
       ;; cue area:
       (setq body-start icon-end)
-      (widget-put item-widget :bullet (setq bullet (allout-get-bullet)))
+      (widget-put item-widget :bullet (allout-get-bullet))
       (if (equal (char-after body-start) ? )
           (setq body-start (1+ body-start)))
       (widget-put item-widget :body-start body-start)
@@ -1784,7 +1799,7 @@ may have subitems.\)"
                        ;; has a subsequent item:
                        (not (= body-end (point-max)))
                        ;; subsequent item is deeper:
-                       (< depth (setq contents-depth (allout-recent-depth))))))
+                       (< depth (allout-recent-depth)))))
     ;; note :expanded - true if widget item's content is currently visible?
     (widget-put item-widget :expanded
                 (and has-subitems
@@ -1793,7 +1808,7 @@ may have subitems.\)"
                        (goto-char allout-recent-prefix-beginning)
                        (not (allout-hidden-p)))))))
 ;;;_   > allout-set-boundary-marker (boundary position &optional current-marker)
-(defun allout-set-boundary-marker (boundary position &optional current-marker)
+(defun allout-set-boundary-marker (_boundary position &optional current-marker)
   "Set or create item widget BOUNDARY type marker at POSITION.
 
 Optional CURRENT-MARKER is the marker currently being used for
@@ -1832,12 +1847,12 @@ the various element spans."
                                     &optional parent-widget has-successor)
   "Add ITEM-WIDGET guide icon-prefix descender and connector text properties.
 
-Optional arguments provide context for deriving the guides.  In
-their absence, the current guide column flags are used.
+Optional arguments provide context for deriving the guides.
+In their absence, the current guide column flags are used.
 
 Optional PARENT-WIDGET is the widget for the item's parent item.
 
-Optional HAS-SUCCESSOR is true iff the item is followed by a sibling.
+Optional HAS-SUCCESSOR is true if the item is followed by a sibling.
 
 We also hide the header-prefix string.
 
@@ -1847,8 +1862,8 @@ reapplying this method will rectify the glyphs."
 
   (when (not (widget-get item-widget :is-container))
     (let* ((depth (widget-get item-widget :depth))
-           (parent-depth (and parent-widget
-                              (widget-get parent-widget :depth)))
+           ;; (parent-depth (and parent-widget
+           ;;                    (widget-get parent-widget :depth)))
            (parent-flags (and parent-widget
                               (widget-get parent-widget :guide-column-flags)))
            (parent-flags-depth (length parent-flags))
@@ -1869,7 +1884,7 @@ reapplying this method will rectify the glyphs."
            (increment (length allout-header-prefix))
            reverse-flags
            guide-name
-           extenders paint-extenders
+           extenders
            (inhibit-read-only t))
 
       (when (not (equal was-flags flags))
@@ -1992,8 +2007,8 @@ reapplying this method will rectify the glyphs."
     (let* ((cue-start (or (widget-get item-widget :distinctive-end)
                           (widget-get item-widget :icon-end)))
            (body-start (widget-get item-widget :body-start))
-           (expanded (widget-get item-widget :expanded))
-           (has-subitems (widget-get item-widget :has-subitems))
+           ;(expanded (widget-get item-widget :expanded))
+           ;(has-subitems (widget-get item-widget :has-subitems))
            (inhibit-read-only t))
 
       (allout-item-element-span-is item-widget :cue-span cue-start body-start)
@@ -2007,7 +2022,6 @@ Optional FORCE means force reassignment of the region property."
   (let* ((allout-inhibit-body-modification-hook t)
          (body-start (widget-get item-widget :body-start))
          (body-end (widget-get item-widget :body-end))
-         (body-text-end body-end)
          (inhibit-read-only t))
 
     (allout-item-element-span-is item-widget :body-span
@@ -2110,9 +2124,7 @@ of the current span, if established, or nil if not yet set.
 When the START and END are passed, return the distance that the
 start of the item moved.  We return 0 if the span was not
 previously established or is not moved."
-  (let ((overlay (widget-get item-widget :span-overlay))
-        was-start was-end
-        changed)
+  (let ((overlay (widget-get item-widget :span-overlay)))
     (cond ((not overlay) (when start
                            (setq overlay (make-overlay start end nil t nil))
                            (overlay-put overlay 'button item-widget)
@@ -2197,7 +2209,7 @@ and decorate its siblings and parent, as well.
 
 Optional BLANK-CONTAINER is for internal use, to fabricate a
 meta-container item with an empty body when the first proper
-\(non-container\) item starts at the beginning of the file.
+\(non-container) item starts at the beginning of the file.
 
 Optional REDECORATE, if non-nil, means to redecorate the widget
 if it already exists."
@@ -2229,12 +2241,12 @@ Point will wind up positioned on the beginning of the parent or beginning
 of the buffer."
   ;; use existing widget, if there, else establish it
   (if (or (bobp) (and (not (allout-ascend))
-                      (looking-at allout-regexp)))
+                      (looking-at-p allout-regexp)))
       (allout-get-or-create-item-widget redecorate 'blank-container)
     (allout-get-or-create-item-widget redecorate)))
 ;;;_  : X- Item ancillaries
 ;;;_   >X allout-body-modification-handler (beg end)
-(defun allout-body-modification-handler (beg end)
+(defun allout-body-modification-handler (_beg _end)
   "Do routine processing of body text before and after modification.
 
 Operation is inhibited by `allout-inhibit-body-modification-handler'."
@@ -2245,7 +2257,7 @@ Operation is inhibited by `allout-inhibit-body-modification-handler'."
 ;; - removal and replacement of the settings
 ;; - maintenance of beginning-of-line guide lines
 ;;
-;; ?? Escapes removal \(before changes\) is not done when edits span multiple
+;; ?? Escapes removal (before changes) is not done when edits span multiple
 ;; items, recognizing that item structure is being preserved, including
 ;; escaping of item-prefix-like text within bodies.  See
 ;; `allout-before-modification-handler' and
@@ -2256,10 +2268,10 @@ Operation is inhibited by `allout-inhibit-body-modification-handler'."
 ;; operation.
   (cond (allout-inhibit-body-modification-hook nil)))
 ;;;_   >X allout-graphics-modification-handler (beg end)
-(defun allout-graphics-modification-handler (beg end)
+(defun allout-graphics-modification-handler (beg _end)
   "Protect against incoherent deletion of decoration graphics.
 
-Deletes allowed only when inhibit-read-only is t."
+Deletes allowed only when `inhibit-read-only' is t."
   (cond
    (undo-in-progress (when (eq (get-text-property beg 'category)
                                'allout-icon-span-category)