]> code.delx.au - gnu-emacs/blobdiff - lisp/allout-widgets.el
Fix the prefix action of shr-copy-url
[gnu-emacs] / lisp / allout-widgets.el
index fd8e5f8ff948744fa9fb8fa80c3cf1108f33b5d2..abcfb2ca5928530d755c856a25bdc612bc332a4d 100644 (file)
@@ -1,6 +1,6 @@
 ;; allout-widgets.el --- Visually highlight allout outline structure.
 
-;; Copyright (C) 2005-2013 Free Software Foundation, Inc.
+;; Copyright (C) 2005-2016 Free Software Foundation, Inc.
 
 ;; Author: Ken Manheimer <ken dot manheimer at gmail...>
 ;; Maintainer: Ken Manheimer <ken dot manheimer at gmail...>
@@ -90,7 +90,6 @@
 
 ;;;_ : USER CUSTOMIZATION VARIABLES and incidental functions:
 ;;;_  > defgroup allout-widgets
-;;;###autoload
 (defgroup allout-widgets nil
   "Allout extension that highlights outline structure graphically.
 
@@ -267,7 +266,7 @@ decreases as obsolete widgets are garbage collected."
 (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.")
@@ -349,7 +348,7 @@ to `allout-body-modification-handler', and is always reset by
 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
+Set this variable to nil to empty the cache, and have it replenish from the
 filesystem.")
 ;;;_    = allout-widgets-unset-inhibit-read-only
 (defvar allout-widgets-unset-inhibit-read-only nil
@@ -385,9 +384,9 @@ The structure includes the guides lines, bullet, and bullet cue.")
 
 Entries on the list are lists whose first element is a symbol indicating
 the change type and subsequent elements are data specific to that change
-type.  Specifically:
+type.  For example:
 
- 'exposure `allout-exposure-from' `allout-exposure-to' `allout-exposure-flag'
+  (exposure ALLOUT-EXPOSURE-FROM ALLOUT-EXPOSURE-TO ALLOUT-EXPOSURE-FLAG)
 
 The changes are recorded in reverse order, with new values pushed
 onto the front.")
@@ -482,9 +481,9 @@ text in allout item bodies.")
 
 \(That space is used to convey selected cues indicating body qualities,
 including things like:
- - encryption '~'
- - numbering '#'
- - indirect reference '@'
+ - encryption `~'
+ - numbering `#'
+ - indirect reference `@'
  - distinctive bullets - see `allout-distinctive-bullets-string'.)")
 ;;;_    = allout-span-to-category
 (defvar allout-span-to-category
@@ -720,17 +719,17 @@ icon/bullet.")
 ;;;_  . Hooks and hook helpers
 ;;;_   , major command-loop business:
 ;;;_    > allout-widgets-pre-command-business (&optional recursing)
-(defun allout-widgets-pre-command-business (&optional recursing)
+(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)
+(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)
 
@@ -811,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? "))
@@ -870,10 +869,10 @@ Optional RECURSING is for internal use, to limit recursion."
     ;; tell the allout-widgets-post-command-business to reestablish the hook:
     (setq allout-widgets-reenable-before-change-handler t)
     ;; and raise an error to prevent the edit (and disable the hook):
-    (error
+    (error "%s"
      (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 ()
@@ -903,7 +902,7 @@ encompassing condition-case."
          (header
           (format "allout-widgets-last-hook-error stored, %s/%s %s %s"
                   this mode args
-                  (format-time-string "%e-%b-%Y %r" (current-time)))))
+                  (format-time-string "%e-%b-%Y %r"))))
     ;; post to *Messages* then immediately replace with more compact notice:
     (message "%s" (setq allout-widgets-last-hook-error
                         (format "%s:\n%s" header bt)))
@@ -999,7 +998,6 @@ Generally invoked via `allout-exposure-change-functions'."
         ;; 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)
 
@@ -1188,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)
@@ -1552,7 +1550,7 @@ 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.
@@ -1593,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))
 
@@ -1615,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)))
@@ -1702,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)
@@ -1753,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
@@ -1783,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)
@@ -1809,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
@@ -1818,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
@@ -1862,7 +1852,7 @@ 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.
 
@@ -1872,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))
@@ -1894,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))
@@ -2017,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)
@@ -2032,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
@@ -2135,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)
@@ -2259,7 +2246,7 @@ of the buffer."
     (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'."
@@ -2281,7 +2268,7 @@ 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."
@@ -2300,7 +2287,7 @@ Deletes allowed only when `inhibit-read-only' is t."
    ((yes-or-no-p "Unruly edit of outline structure - allow? ")
     (setq allout-widgets-unset-inhibit-read-only (not inhibit-read-only)
           inhibit-read-only t))
-   (t (error
+   (t (error "%s"
        (substitute-command-keys allout-structure-unruly-deletion-message)))))
 ;;;_   > allout-item-icon-key-handler ()
 (defun allout-item-icon-key-handler ()
@@ -2355,9 +2342,9 @@ We use a caching strategy, so the caller doesn't need to do so."
       got)))
 
 ;;;_ : Miscellaneous
-;;;_  > allout-elapsed-time-seconds (triple)
+;;;_  > allout-elapsed-time-seconds (time-value time-value)
 (defun allout-elapsed-time-seconds (end start)
-  "Return seconds between `current-time' style time START/END triples."
+  "Return seconds between START/END time values."
   (let ((elapsed (time-subtract end start)))
     (float-time elapsed)))
 ;;;_  > allout-frame-property (frame property)
@@ -2385,7 +2372,7 @@ The elements of LIST are not copied, just the list structure itself."
     (car list)))
 ;;;_  . allout-widgets-count-buttons-in-region (start end)
 (defun allout-widgets-count-buttons-in-region (start end)
-  "Debugging/diagnostic tool - count overlays with 'button' property in region."
+  "Debugging/diagnostic tool - count overlays with `button' property in region."
   (interactive "r")
   (setq start (or start (point-min))
         end (or end (point-max)))