]> code.delx.au - gnu-emacs/blobdiff - lisp/progmodes/idlw-shell.el
Merge from cygw32 branch
[gnu-emacs] / lisp / progmodes / idlw-shell.el
index a57fba4e822be2a2ecf54f6863660426a8e82a75..0abd4daf61b9279b526c0bfa506bfbc8f451f422 100644 (file)
@@ -1,14 +1,14 @@
 ;; idlw-shell.el --- run IDL as an inferior process of Emacs.
 
-;; Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009
-;;    Free Software Foundation, Inc.
+;; Copyright (C) 1999-2012  Free Software Foundation, Inc.
 
 ;; Authors: J.D. Smith <jdsmith@as.arizona.edu>
 ;;          Carsten Dominik <dominik@astro.uva.nl>
 ;;          Chris Chase <chase@att.com>
 ;; Maintainer: J.D. Smith <jdsmith@as.arizona.edu>
-;; Version: 6.1_em22
+;; Version: 6.1.22
 ;; Keywords: processes
+;; Package: idlwave
 
 ;; This file is part of GNU Emacs.
 
@@ -48,7 +48,7 @@
 ;;
 ;; Follow the instructions in the INSTALL file of the distribution.
 ;; In short, put this file on your load path and add the following
-;; lines to your .emacs file:
+;; lines to your init file:
 ;;
 ;; (autoload 'idlwave-shell "idlw-shell" "IDLWAVE Shell" t)
 ;;
   :group 'idlwave)
 
 (defcustom idlwave-shell-prompt-pattern "^\r? ?IDL> "
-  "*Regexp to match IDL prompt at beginning of a line.
+  "Regexp to match IDL prompt at beginning of a line.
 For example, \"^\r?IDL> \" or \"^\r?WAVE> \".
 The \"^\r?\" is needed, to indicate the beginning of the line, with
 optional return character (which IDL seems to output randomly).
 This variable is used to initialize `comint-prompt-regexp' in the
-process buffer.
-
-This is a fine thing to set in your `.emacs' file."
+process buffer."
   :group 'idlwave-shell-general-setup
   :type 'regexp)
 
 (defcustom idlwave-shell-process-name "idl"
-  "*Name to be associated with the IDL process.  The buffer for the
+  "Name to be associated with the IDL process.  The buffer for the
 process output is made by surrounding this name with `*'s."
   :group 'idlwave-shell-general-setup
   :type 'string)
@@ -126,12 +124,12 @@ process output is made by surrounding this name with `*'s."
 ;; (defcustom idlwave-shell-automatic-start...)  See idlwave.el
 
 (defcustom idlwave-shell-use-dedicated-window nil
-  "*Non-nil means, never replace the shell frame with another buffer."
+  "Non-nil means, never replace the shell frame with another buffer."
   :group 'idlwave-shell-general-setup
   :type 'boolean)
 
 (defcustom idlwave-shell-use-dedicated-frame nil
-  "*Non-nil means, IDLWAVE should use a special frame to display shell buffer."
+  "Non-nil means, IDLWAVE should use a special frame to display shell buffer."
   :group 'idlwave-shell-general-setup
   :type 'boolean)
 
@@ -145,12 +143,12 @@ The default makes the frame splittable, so that completion works correctly."
          (cons symbol sexp)))
 
 (defcustom idlwave-shell-raise-frame t
-  "*Non-nil means, `idlwave-shell' raises the frame showing the shell window."
+  "Non-nil means, `idlwave-shell' raises the frame showing the shell window."
   :group 'idlwave-shell-general-setup
   :type 'boolean)
 
 (defcustom idlwave-shell-arrows-do-history t
-  "*Non-nil means UP and DOWN arrows move through command history.
+  "Non-nil means UP and DOWN arrows move through command history.
 This variable can have 3 values:
 nil        Arrows just move the cursor
 t          Arrows force the cursor back to the current command line and
@@ -166,7 +164,7 @@ t          Arrows force the cursor back to the current command line and
 ;; FIXME: add comint-input-ring-size?
 
 (defcustom idlwave-shell-use-toolbar t
-  "*Non-nil means, use the debugging toolbar in all IDL related buffers.
+  "Non-nil means, use the debugging toolbar in all IDL related buffers.
 Starting the shell will then add the toolbar to all idlwave-mode buffers.
 Exiting the shell will removed everywhere.
 Available on XEmacs and on Emacs 21.x or later.
@@ -176,21 +174,15 @@ At any time you can toggle the display of the toolbar with
   :type 'boolean)
 
 (defcustom idlwave-shell-temp-pro-prefix "/tmp/idltemp"
-  "*The prefix for temporary IDL files used when compiling regions.
+  "The prefix for temporary IDL files used when compiling regions.
 It should be an absolute pathname.
 The full temporary file name is obtained by using `make-temp-file'
 so that the name will be unique among multiple Emacs processes."
   :group 'idlwave-shell-general-setup
   :type 'string)
 
-(defvar idlwave-shell-fix-inserted-breaks nil
-  "*OBSOLETE VARIABLE, is no longer used.
-
-The documentation of this variable used to be:
-If non-nil then run `idlwave-shell-remove-breaks' to clean up IDL messages.")
-
 (defcustom idlwave-shell-prefix-key "\C-c\C-d"
-  "*The prefix key for the debugging map `idlwave-shell-mode-prefix-map'.
+  "The prefix key for the debugging map `idlwave-shell-mode-prefix-map'.
 This variable must already be set when idlwave-shell.el is loaded.
 Setting it in the mode-hook is too late."
   :group 'idlwave-shell-general-setup
@@ -223,11 +215,8 @@ window, but is useful for stepping, etc."
 
 ;; (defcustom idlwave-shell-debug-modifiers... See idlwave.el
 
-(defvar idlwave-shell-activate-alt-keybindings nil
-  "Obsolete variable.  See `idlwave-shell-debug-modifiers'.")
-
 (defcustom idlwave-shell-use-truename nil
-  "*Non-nil means, use use `file-truename' when looking for buffers.
+  "Non-nil means, use `file-truename' when looking for buffers.
 If this variable is non-nil, Emacs will use the function `file-truename' to
 resolve symbolic links in the file paths printed by e.g., STOP commands.
 This means, unvisited files will be loaded under their truename.
@@ -241,13 +230,13 @@ to set this option to nil."
 
 (defcustom idlwave-shell-file-name-chars "~/A-Za-z0-9+:_.$#%={}\\- "
   "The characters allowed in file names, as a string.
-Used for file name completion. Must not contain `'', `,' and `\"'
+Used for file name completion.  Must not contain `'', `,' and `\"'
 because these are used as separators by IDL."
   :group 'idlwave-shell-general-setup
   :type 'string)
 
 (defcustom idlwave-shell-mode-hook '()
-  "*Hook for customising `idlwave-shell-mode'."
+  "Hook for customizing `idlwave-shell-mode'."
   :group 'idlwave-shell-general-setup
   :type 'hook)
 
@@ -292,7 +281,7 @@ is non-nil."
 
 (defcustom idlwave-shell-show-commands
   '(run misc breakpoint)
-  "*A list of command types to show output from in the shell.
+  "A list of command types to show output from in the shell.
 Possibilities are 'run, 'debug, 'breakpoint, and 'misc.  Unselected
 types are not displayed in the shell.  The type 'everything causes all
 the copious shell traffic to be displayed."
@@ -335,11 +324,8 @@ expression being examined."
           (string :tag "Label  ")
           (string :tag "Command"))))
 
-(defvar idlwave-shell-print-expression-function nil
-  "*OBSOLETE VARIABLE, is no longer used.")
-
 (defcustom idlwave-shell-separate-examine-output t
-  "*Non-nil mean, put output of examine commands in their own buffer."
+  "Non-nil means, put output of examine commands in their own buffer."
   :group 'idlwave-shell-command-setup
   :type 'boolean)
 
@@ -359,12 +345,12 @@ newly created."
          (cons variable sexp)))
 
 (defcustom idlwave-shell-query-for-class t
-  "*Non-nil means query the shell for object class on object completions."
+  "Non-nil means query the shell for object class on object completions."
   :group 'idlwave-shell-command-setup
   :type 'boolean)
 
 (defcustom idlwave-shell-use-input-mode-magic nil
-  "*Non-nil means, IDLWAVE should check for input mode spells in output.
+  "Non-nil means, IDLWAVE should check for input mode spells in output.
 The spells are strings printed by your IDL program and matched
 by the regular expressions in `idlwave-shell-input-mode-spells'.
 When these expressions match, IDLWAVE switches to character input mode and
@@ -432,7 +418,7 @@ end"
          (regexp :tag "Line-mode regexp")))
 
 (defcustom idlwave-shell-breakpoint-popup-menu t
-  "*If non-nil, provide a menu on mouse-3 on breakpoint lines, and
+  "If non-nil, provide a menu on mouse-3 on breakpoint lines, and
 popup help text on the line."
   :group 'idlwave-shell-command-setup
   :type 'boolean)
@@ -444,12 +430,12 @@ popup help text on the line."
 
 ;; Breakpoint Overlays etc
 (defgroup idlwave-shell-highlighting-and-faces nil
-  "Highlighting and Faces used by the IDLWAVE Shell mode."
+  "Highlighting and faces used by the IDLWAVE Shell mode."
   :prefix "idlwave-shell"
   :group 'idlwave)
 
 (defcustom idlwave-shell-mark-stop-line t
-  "*Non-nil means, mark the source code line where IDL is currently stopped.
+  "Non-nil means, mark the source code line where IDL is currently stopped.
 Value decides about the method which is used to mark the line.  Valid values
 are:
 
@@ -471,7 +457,7 @@ hides any code, so setting this to 'arrow on Emacs 21 sounds like a good idea."
          (const :tag "Face or arrow." t)))
 
 (defcustom idlwave-shell-overlay-arrow ">"
-  "*The overlay arrow to display at source lines where execution halts.
+  "The overlay arrow to display at source lines where execution halts.
 We use a single character by default, since the main block of IDL procedures
 often has no indentation.  Where possible, IDLWAVE will use overlays to
 display the stop-lines.  The arrow is only used on character-based terminals.
@@ -480,33 +466,33 @@ See also `idlwave-shell-use-overlay-arrow'."
   :type 'string)
 
 (defcustom idlwave-shell-stop-line-face 'highlight
-  "*The face for `idlwave-shell-stop-line-overlay'.
+  "The face for `idlwave-shell-stop-line-overlay'.
 Allows you to choose the font, color and other properties for
 line where IDL is stopped.  See also `idlwave-shell-mark-stop-line'."
   :group 'idlwave-shell-highlighting-and-faces
   :type 'symbol)
 
 (defcustom idlwave-shell-electric-stop-color "Violet"
-  "*The color for the default face or overlay arrow when stopped."
+  "The color for the default face or overlay arrow when stopped."
   :group 'idlwave-shell-highlighting-and-faces
   :type 'string)
 
 (defcustom idlwave-shell-electric-stop-line-face
   (prog1
-      (copy-face 'modeline 'idlwave-shell-electric-stop-line)
+      (copy-face 'mode-line 'idlwave-shell-electric-stop-line)
     (set-face-background 'idlwave-shell-electric-stop-line
                         idlwave-shell-electric-stop-color)
     (condition-case nil
        (set-face-foreground 'idlwave-shell-electric-stop-line nil)
       (error nil)))
-  "*The face for `idlwave-shell-stop-line-overlay' when in electric debug mode.
+  "The face for `idlwave-shell-stop-line-overlay' when in electric debug mode.
 Allows you to choose the font, color and other properties for the line
 where IDL is stopped, when in Electric Debug Mode."
   :group 'idlwave-shell-highlighting-and-faces
   :type 'symbol)
 
 (defcustom idlwave-shell-mark-breakpoints t
-  "*Non-nil means, mark breakpoints in the source files.
+  "Non-nil means, mark breakpoints in the source files.
 Valid values are:
 nil        Do not mark breakpoints.
 'face      Highlight line with `idlwave-shell-breakpoint-face'.
@@ -520,11 +506,8 @@ t          Glyph when possible, otherwise face (same effect as 'glyph)."
          (const :tag "Display glyph (red dot)" glyph)
          (const :tag "Glyph or face." t)))
 
-(defvar idlwave-shell-use-breakpoint-glyph t
-  "Obsolete variable.  See `idlwave-shell-mark-breakpoints.")
-
 (defcustom idlwave-shell-breakpoint-face 'idlwave-shell-bp
-  "*The face for breakpoint lines in the source code.
+  "The face for breakpoint lines in the source code.
 Allows you to choose the font, color and other properties for
 lines which have a breakpoint.  See also `idlwave-shell-mark-breakpoints'."
   :group 'idlwave-shell-highlighting-and-faces
@@ -542,7 +525,7 @@ lines which have a breakpoint.  See also `idlwave-shell-mark-breakpoints'."
 
 (defcustom idlwave-shell-disabled-breakpoint-face
   'idlwave-shell-disabled-bp
-  "*The face for disabled breakpoint lines in the source code.
+  "The face for disabled breakpoint lines in the source code.
 Allows you to choose the font, color and other properties for
 lines which have a breakpoint.  See also `idlwave-shell-mark-breakpoints'."
   :group 'idlwave-shell-highlighting-and-faces
@@ -560,14 +543,14 @@ lines which have a breakpoint.  See also `idlwave-shell-mark-breakpoints'."
 
 
 (defcustom idlwave-shell-expression-face 'secondary-selection
-  "*The face for `idlwave-shell-expression-overlay'.
+  "The face for `idlwave-shell-expression-overlay'.
 Allows you to choose the font, color and other properties for
 the expression printed by IDL."
   :group 'idlwave-shell-highlighting-and-faces
   :type 'symbol)
 
 (defcustom idlwave-shell-output-face 'secondary-selection
-  "*The face for `idlwave-shell-output-overlay'.
+  "The face for `idlwave-shell-output-overlay'.
 Allows you to choose the font, color and other properties for
 the expression output by IDL."
   :group 'idlwave-shell-highlighting-and-faces
@@ -640,7 +623,7 @@ the directory stack.")
   "The command which gets !PATH and !DIR info from the shell.")
 
 (defvar idlwave-shell-mode-line-info nil
-  "Additional info displayed in the mode line")
+  "Additional info displayed in the mode line.")
 
 (defvar idlwave-shell-default-directory nil
   "The default directory in the idlwave-shell buffer, of outside use.")
@@ -722,7 +705,7 @@ the directory stack.")
 
 
 (defvar idlwave-shell-bp-query "help,/breakpoints"
-  "Command to obtain list of breakpoints")
+  "Command to obtain list of breakpoints.")
 
 (defvar idlwave-shell-command-output nil
   "String for accumulating current command output.")
@@ -733,11 +716,10 @@ The current command is finished when the IDL prompt is displayed.
 This is evaluated if it is a list or called with funcall.")
 
 (defvar idlwave-shell-sentinel-hook nil
-  "Hook run when the idl process exits.")
+  "Hook run when the IDL process exits.")
 
 (defvar idlwave-shell-hide-output nil
-  "If non-nil the process output is not inserted into the output
-buffer.")
+  "If non-nil the process output is not inserted into the output buffer.")
 
 (defvar idlwave-shell-show-if-error nil
   "If non-nil the process output is inserted into the output buffer if
@@ -754,12 +736,12 @@ it contains an error message, even if hide-output is non-nil.")
   "List of commands to be sent to IDL.
 Each element of the list is list of \(CMD PCMD HIDE\), where CMD is a
 string to be sent to IDL and PCMD is a post-command to be placed on
-`idlwave-shell-post-command-hook'. If HIDE is non-nil, hide the output
-from command CMD. PCMD and HIDE are optional.")
+`idlwave-shell-post-command-hook'.  If HIDE is non-nil, hide the output
+from command CMD.  PCMD and HIDE are optional.")
 
 (defun idlwave-shell-buffer ()
   "Name of buffer associated with IDL process.
-The name of the buffer is made by surrounding `idlwave-shell-process-name
+The name of the buffer is made by surrounding `idlwave-shell-process-name'
 with `*'s."
   (concat "*" idlwave-shell-process-name "*"))
 
@@ -785,30 +767,30 @@ with `*'s."
     "^% Skipped to:"
     "^% Stop encountered:"
     )
-  "*A list of regular expressions matching IDL messages.
+  "A list of regular expressions matching IDL messages.
 These are the messages containing file and line information where
 IDL is currently stopped.")
 
 
 (defconst idlwave-shell-halt-messages-re
   (mapconcat 'identity idlwave-shell-halt-messages "\\|")
-  "The regular expression computed from idlwave-shell-halt-messages")
+  "The regular expression computed from `idlwave-shell-halt-messages'.")
 
 (defconst idlwave-shell-trace-message-re
   "^% At "    ;; First line of a trace message
-  "*A regular expression matching IDL trace messages.  These are the
+  "A regular expression matching IDL trace messages.  These are the
 messages containing file and line information of a current
 traceback.")
 
 (defconst idlwave-shell-step-messages
   '("^% Stepped to:"
     )
-  "*A list of regular expressions matching stepped execution messages.
+  "A list of regular expressions matching stepped execution messages.
 These are IDL messages containing file and line information where
 IDL has currently stepped.")
 
 (defvar idlwave-shell-break-message "^% Breakpoint at:"
-  "*Regular expression matching an IDL breakpoint message line.")
+  "Regular expression matching an IDL breakpoint message line.")
 
 (defconst idlwave-shell-electric-debug-help
   "   ==> IDLWAVE Electric Debug Mode Help <==
@@ -866,15 +848,15 @@ IDL has currently stepped.")
 (defvar idlwave-shell-only-prompt-pattern nil)
 (defvar tool-bar-map)
 
-(defun idlwave-shell-mode ()
+(define-derived-mode idlwave-shell-mode comint-mode "IDL-Shell"
   "Major mode for interacting with an inferior IDL process.
 
 1. Shell Interaction
    -----------------
    RET after the end of the process' output sends the text from the
    end of process to the end of the current line.  RET before end of
-   process output copies the current line (except for the prompt) to the
-   end of the buffer.
+   process output copies the current line (except for the prompt) to
+   the end of the buffer.
 
    Command history, searching of previous commands, command line
    editing are available via the comint-mode key bindings, by default
@@ -926,7 +908,7 @@ IDL has currently stepped.")
    \\[idlwave-shell-print] or \\[idlwave-shell-mouse-print] with the
    mouse, help, \\[idlwave-shell-help-expression] or
    \\[idlwave-shell-mouse-help] with the mouse, or with a
-   configureable set of custom examine commands using
+   configurable set of custom examine commands using
    \\[idlwave-shell-examine-select].  The mouse examine commands can
    also work by click and drag, to select an expression for
    examination.
@@ -940,35 +922,30 @@ IDL has currently stepped.")
    -------------------------------
    Info documentation for this package is available.  Use \\[idlwave-info]
    to display (complain to your sysadmin if that does not work).
-   For Postscript and HTML versions of the documentation, check IDLWAVE's
+   For PostScript and HTML versions of the documentation, check IDLWAVE's
    homepage at URL `http://idlwave.org'.
    IDLWAVE has customize support - see the group `idlwave'.
 
 8. Keybindings
    -----------
 \\{idlwave-shell-mode-map}"
-
-  (interactive)
+  :abbrev-table idlwave-mode-abbrev-table
   (idlwave-setup) ; Make sure config files and paths, etc. are available.
   (unless (file-name-absolute-p idlwave-shell-command-history-file)
     (setq idlwave-shell-command-history-file
          (expand-file-name idlwave-shell-command-history-file
                            idlwave-config-directory)))
 
-  ;; We don't do `kill-all-local-variables' here, because this is done by
-  ;; comint
   (setq comint-prompt-regexp idlwave-shell-prompt-pattern)
   (setq comint-process-echoes t)
 
   ;; Can not use history expansion because "!" is used for system variables.
   (setq comint-input-autoexpand nil)
- (setq comint-input-ring-size 64)
-  (make-local-variable 'comint-completion-addsuffix)
+  ;; (setq comint-input-ring-size 64)
+
   (set (make-local-variable 'completion-ignore-case) t)
-  (setq comint-completion-addsuffix '("/" . ""))
+  (set (make-local-variable 'comint-completion-addsuffix) '("/" . ""))
   (setq comint-input-ignoredups t)
-  (setq major-mode 'idlwave-shell-mode)
-  (setq mode-name "IDL-Shell")
   (setq idlwave-shell-mode-line-info nil)
   (setq mode-line-format
        '(""
@@ -1023,7 +1000,6 @@ IDL has currently stepped.")
            nil 'local)
   (add-hook 'kill-buffer-hook 'idlwave-shell-delete-temp-files nil 'local)
   (add-hook 'kill-emacs-hook 'idlwave-shell-delete-temp-files)
-  (use-local-map idlwave-shell-mode-map)
   (easy-menu-add idlwave-shell-mode-menu idlwave-shell-mode-map)
 
   ;; Set the optional comint variables
@@ -1054,10 +1030,7 @@ IDL has currently stepped.")
   ;; with overlay-arrows.
   (remove-hook 'comint-output-filter-functions 'py-pdbtrack-track-stack-file)
 
-
   ;; IDLWAVE syntax, and turn on abbreviations
-  (setq local-abbrev-table idlwave-mode-abbrev-table)
-  (set-syntax-table idlwave-mode-syntax-table)
   (set (make-local-variable 'comment-start) ";")
   (setq abbrev-mode t)
 
@@ -1076,8 +1049,6 @@ IDL has currently stepped.")
   ;; Turn off the non-debug toolbar buttons (open,save,etc.)
   (set (make-local-variable 'tool-bar-map) nil)
 
-  ;; Run the hooks.
-  (run-mode-hooks 'idlwave-shell-mode-hook)
   (idlwave-shell-send-command idlwave-shell-initial-commands nil 'hide)
   ;; Turn off IDL's ^d interpreting, and define a system
   ;; variable which knows the version of IDLWAVE
@@ -1126,9 +1097,9 @@ IDL has currently stepped.")
     (fset 'idl-shell 'idlwave-shell))
 
 (defvar idlwave-shell-idl-wframe nil
-  "Frame for displaying the idl shell window.")
+  "Frame for displaying the IDL shell window.")
 (defvar idlwave-shell-display-wframe nil
-  "Frame for displaying the idl source files.")
+  "Frame for displaying the IDL source files.")
 
 (defvar idlwave-shell-calling-stack-index 0)
 (defvar idlwave-shell-calling-stack-routine nil)
@@ -1271,9 +1242,9 @@ Return either nil or 'hide."
                                             show-if-error)
   "Send a command to IDL process.
 
-\(CMD PCMD HIDE\) are placed at the end of `
-idlwave-shell-pending-commands'.  If IDL is ready the first command,
-CMD, in `idlwave-shell-pending-commands' is sent to the IDL process.
+\(CMD PCMD HIDE\) are placed at the end of `idlwave-shell-pending-commands'.
+If IDL is ready the first command in `idlwave-shell-pending-commands',
+CMD, is sent to the IDL process.
 
 If optional second argument PCMD is non-nil it will be placed on
 `idlwave-shell-post-command-hook' when CMD is executed.
@@ -1287,7 +1258,7 @@ stepping through code with output.
 If optional fourth argument PREEMPT is non-nil CMD is put at front of
 `idlwave-shell-pending-commands'.  If PREEMPT is 'wait, wait for all
 output to complete and the next prompt to arrive before returning
-\(useful if you need an answer now\). IDL is considered ready if the
+\(useful if you need an answer now\).  IDL is considered ready if the
 prompt is present and if `idlwave-shell-ready' is non-nil.
 
 If SHOW-IF-ERROR is non-nil, show the output if it contains an error
@@ -1458,7 +1429,7 @@ Otherwise just move the line.  Move down unless UP is non-nil."
         (arg (if up arg (- arg))))
     (if (eq t idlwave-shell-arrows-do-history) (goto-char proc-pos))
     (if (and idlwave-shell-arrows-do-history
-            (>= (1+ (save-excursion (end-of-line) (point))) proc-pos))
+            (>= (1+ (point-at-eol)) proc-pos))
        (comint-previous-input arg)
       (forward-line (- arg)))))
 
@@ -1542,11 +1513,11 @@ and then calls `idlwave-shell-send-command' for any pending commands."
                      (concat idlwave-shell-accumulation string)))
 
 
-;;; Test/Debug code
-             ;(with-current-buffer
-             ;   (get-buffer-create "*idlwave-shell-output*")
-             ; (goto-char (point-max))
-             ; (insert "\nReceived STRING\n===>\n" string "\n<====\n"))
+              ;; ;; Test/Debug code
+             ;;(with-current-buffer
+             ;   (get-buffer-create "*idlwave-shell-output*")
+             ; (goto-char (point-max))
+             ; (insert "\nReceived STRING\n===>\n" string "\n<====\n"))
 
              ;; Check for prompt in current accumulating output
              (when (setq idlwave-shell-ready
@@ -1554,8 +1525,7 @@ and then calls `idlwave-shell-send-command' for any pending commands."
                                        idlwave-shell-accumulation))
                ;; Gather the command output
                (if idlwave-shell-hide-output
-                   (save-excursion
-                     (set-buffer idlwave-shell-hidden-output-buffer)
+                   (with-current-buffer idlwave-shell-hidden-output-buffer
                      (setq full-output (buffer-string))
                      (goto-char (point-max))
                      (re-search-backward idlwave-shell-prompt-pattern nil t)
@@ -1609,7 +1579,7 @@ and then calls `idlwave-shell-send-command' for any pending commands."
                        idlwave-shell-post-command-hook nil
                        idlwave-shell-hide-output nil
                        idlwave-shell-show-if-error nil))
-               ;; Done with post command. Do pending command if
+               ;; Done with post command.  Do pending command if
                ;; any.
                (idlwave-shell-send-command)))
          (store-match-data data)))))
@@ -1619,8 +1589,7 @@ and then calls `idlwave-shell-send-command' for any pending commands."
   (let* ((buf (idlwave-shell-buffer))
         (win (get-buffer-window buf)))
     (when (get-buffer buf)
-      (save-excursion
-       (set-buffer (idlwave-shell-buffer))
+      (with-current-buffer (idlwave-shell-buffer)
        (goto-char (point-max))
        (insert (format "\n\n  Process %s %s" process event))
        (if (and idlwave-shell-save-command-history
@@ -1640,8 +1609,7 @@ and then calls `idlwave-shell-send-command' for any pending commands."
     (idlwave-shell-cleanup)
     ;; Run the hook, if possible in the shell buffer.
     (if (get-buffer buf)
-       (save-excursion
-         (set-buffer buf)
+       (with-current-buffer buf
          (run-hooks 'idlwave-shell-sentinel-hook))
       (run-hooks 'idlwave-shell-sentinel-hook))))
 
@@ -1654,7 +1622,7 @@ and then calls `idlwave-shell-send-command' for any pending commands."
 (defvar idlwave-shell-syntax-error
   "^% Syntax error.\\s-*\n\\s-*At:\\s-*\\(.*\\),\\s-*Line\\s-*\\(.*\\)"
   "A regular expression to match an IDL syntax error.
-The 1st pair matches the file name, the second pair matches the line
+The first pair matches the file name, the second pair matches the line
 number.")
 
 (defvar idlwave-shell-other-error
@@ -1687,7 +1655,7 @@ number.")
    "\\([ \t]*\n[ \t]*[^ \t\n]+\\)*"      ; continuation lines file name (6)
    "\\)"                                 ; end line number group (5)
    )
-  "*A regular expression to parse out the file name and line number.
+  "A regular expression to parse out the file name and line number.
 The 1st group should match the subroutine name.
 The 3rd group is the line number.
 The 5th group is the file name.
@@ -1697,13 +1665,14 @@ in IDL5 which inserts random linebreaks in long module and file names.")
 (defvar idlwave-shell-electric-debug-mode) ; defined by easy-mmode
 
 (defun idlwave-shell-scan-for-state ()
-  "Scan for state info.  Looks for messages in output from last IDL
-command indicating where IDL has stopped. The types of messages we are
-interested in are execution halted, stepped, breakpoint, interrupted
-at and trace messages.  For breakpoint messages process any attached
-count or command parameters.  Update the stop line if a message is
-found.  The variable `idlwave-shell-current-state' is set to 'error,
-'halt, or 'breakpoint, which describes the status, or nil for none of
+  "Scan for state info.
+Looks for messages in output from last IDL command indicating where
+IDL has stopped.  The types of messages we are interested in are
+execution halted, stepped, breakpoint, interrupted at and trace
+messages.  For breakpoint messages process any attached count or
+command parameters.  Update the stop line if a message is found.
+The variable `idlwave-shell-current-state' is set to 'error, 'halt,
+or 'breakpoint, which describes the status, or nil for none of
 the above."
   (let (trace)
     (cond
@@ -1858,7 +1827,7 @@ file name."
     (cond
      ((file-regular-p file2) file2)
      ((file-regular-p file1) file1)
-     ;; If we cannot veryfy the existence of the file, we return the shorter
+     ;; If we cannot verify the existence of the file, we return the shorter
      ;; name.  The idea behind this is that this may be a relative file name
      ;; and our idea about the current working directory may be wrong.
      ;; If it is a relative file name, it hopefully is short.
@@ -1936,7 +1905,7 @@ Also get rid of widget events in the queue."
                              (idlwave-shell-hide-p 'misc) nil t))
 
 (defun idlwave-shell-quit (&optional arg)
-  "Exit the idl process after confirmation.
+  "Exit the IDL process after confirmation.
 With prefix ARG, exit without confirmation."
   (interactive "P")
   (if (not (idlwave-shell-is-running))
@@ -2088,13 +2057,12 @@ HEAP_GC, /VERBOSE"
 (defun idlwave-shell-filter-directory ()
   "Get the current directory from `idlwave-shell-command-output'.
 Change the default directory for the process buffer to concur."
-  (save-excursion
-    (set-buffer (idlwave-shell-buffer))
+  (with-current-buffer (idlwave-shell-buffer)
     (if (string-match ",___cur[\n\r ]+\\([^\n\r]+\\)[\n\r]"
                      idlwave-shell-command-output)
        (let ((dir (substring idlwave-shell-command-output
                              (match-beginning 1) (match-end 1))))
-;        (message "Setting Emacs working dir to %s" dir)
+          ;; (message "Setting Emacs working dir to %s" dir)
          (setq idlwave-shell-default-directory dir)
          (setq default-directory (file-name-as-directory dir))))))
 
@@ -2183,8 +2151,8 @@ keywords."
       ;; Default completion of modules and keywords
       (idlwave-complete arg)))))
 
-;; Get rid of opaque dynamic variable passing of link?
-(defvar link) ;dynamic variable
+;; Get rid of opaque dynamic variable passing of idlw-help-link?
+(defvar idlw-help-link) ; dynamic variable from idlwave-do-mouse-completion-help
 (defun idlwave-shell-complete-execcomm-help (mode word)
   (let ((word (or (nth 1 idlwave-completion-help-info) word))
        (entry (assoc-string word idlwave-executive-commands-alist t)))
@@ -2192,7 +2160,7 @@ keywords."
      ((eq mode 'test)
       (and (stringp word) entry (cdr entry)))
      ((eq mode 'set)
-      (if entry (setq link (cdr entry)))) ;; setting dynamic variable!!!
+      (if entry (setq idlw-help-link (cdr entry)))) ; setting dynamic variable!
      (t (error "This should not happen")))))
 
 (defun idlwave-shell-complete-filename (&optional arg)
@@ -2202,7 +2170,7 @@ args of an executive .run, .rnew or .compile."
   ;; CWD might have changed, resync, to set default directory
   (idlwave-shell-resync-dirs)
   (let ((comint-file-name-chars idlwave-shell-file-name-chars))
-    (comint-dynamic-complete-as-filename)))
+    (comint-dynamic-complete-filename)))
 
 (defun idlwave-shell-executive-command ()
   "Return the name of the current executive command, if any."
@@ -2214,7 +2182,7 @@ args of an executive .run, .rnew or .compile."
 
 (defun idlwave-shell-filename-string ()
   "Return t if in a string and after what could be a file name."
-  (let ((limit (save-excursion (beginning-of-line) (point))))
+  (let ((limit (point-at-bol)))
     (save-excursion
       ;; Skip backwards over file name chars
       (skip-chars-backward idlwave-shell-file-name-chars limit)
@@ -2222,8 +2190,8 @@ args of an executive .run, .rnew or .compile."
       (memq (preceding-char) '(?\' ?\")))))
 
 (defun idlwave-shell-batch-command ()
-  "Returns t if we're in a batch command statement like @foo"
-  (let ((limit (save-excursion (beginning-of-line) (point))))
+  "Return t if we're in a batch command statement like @foo"
+  (let ((limit (point-at-bol)))
     (save-excursion
       ;; Skip backwards over filename
       (skip-chars-backward idlwave-shell-file-name-chars limit)
@@ -2231,7 +2199,7 @@ args of an executive .run, .rnew or .compile."
       (and (eq (preceding-char) ?@) (not (idlwave-in-quote))))))
 
 (defun idlwave-shell-shell-command ()
-  "Returns t if we're in a shell command statement like $ls"
+  "Return t if we're in a shell command statement like $ls"
   (save-excursion
     (idlwave-beginning-of-statement)
     (looking-at "\\$")))
@@ -2239,7 +2207,7 @@ args of an executive .run, .rnew or .compile."
 ;; Debugging Commands ------------------------------------------------------
 
 (defun idlwave-shell-redisplay (&optional hide)
-  "Tries to resync the display with where execution has stopped.
+  "Try to resync the display with where execution has stopped.
 Issues a \"help,/trace\" command followed by a call to
 `idlwave-shell-display-line'.  Also updates the breakpoint
 overlays."
@@ -2309,18 +2277,19 @@ overlays."
 
 (defun idlwave-shell-goto-frame (&optional frame)
   "Set buffer to FRAME with point at the frame line.
-If the optional argument FRAME is nil then idlwave-shell-pc-frame is
-used.  Does nothing if the resulting frame is nil."
+If the optional argument FRAME is nil then `idlwave-shell-pc-frame'
+is used.  Does nothing if the resulting frame is nil."
   (if frame ()
     (setq frame (idlwave-shell-pc-frame)))
   (cond
    (frame
     (set-buffer (idlwave-find-file-noselect (car frame) 'shell))
     (widen)
-    (goto-line (nth 1 frame)))))
+    (goto-char (point-min))
+    (forward-line (1- (nth 1 frame))))))
 
 (defun idlwave-shell-pc-frame ()
-  "Returns the frame for IDL execution."
+  "Return the frame for IDL execution."
   (and idlwave-shell-halt-frame
        (list (nth 0 idlwave-shell-halt-frame)
             (nth 1 idlwave-shell-halt-frame)
@@ -2340,13 +2309,13 @@ used.  Does nothing if the resulting frame is nil."
 
 (defvar idlwave-shell-suppress-electric-debug nil)
 (defun idlwave-shell-display-line (frame &optional col debug)
-  "display frame file in other window with overlay arrow.
+  "Display frame file in other window with overlay arrow.
 
-frame is a list of file name, line number, and subroutine name.  if
-frame is nil then remove overlay.  if col is set, move point to that
-column in the line.  if debug is non-nil, enable the electric debug
-mode.  if it is 'disable, do not enable no matter what the setting of
-'idlwave-shell-automatic-electric-debug'.  if it is 'force, enable no
+FRAME is a list of file name, line number, and subroutine name.  If
+FRAME is nil then remove overlay.  If COL is set, move point to that
+column in the line.  If DEBUG is non-nil, enable the electric debug
+mode.  If it is 'disable, do not enable no matter what the setting of
+`idlwave-shell-automatic-electric-debug'.  If it is 'force, enable no
 matter what the settings of that variable."
   (if (not frame)
       ;; remove stop-line overlay from old position
@@ -2362,10 +2331,10 @@ matter what the settings of that variable."
        ;; fixme: errors are dangerous in shell filters.  but i think i
        ;; have never encountered this one.
         (error "invalid frame - unable to access file: %s" (car frame))
-;;;
-;;; buffer : the buffer to display a line in.
-;;; select-shell: current buffer is the shell.
-;;;
+      ;;
+      ;; buffer : the buffer to display a line in.
+      ;; select-shell: current buffer is the shell.
+      ;;
       (setq idlwave-shell-mode-line-info
            (if (nth 2 frame)
                (format "[%d:%s]"
@@ -2384,12 +2353,11 @@ matter what the settings of that variable."
                                             nil (idlwave-shell-source-frame)))
 
        ;; enter the buffer and mark the line
-        (save-excursion
-          (set-buffer buffer)
+        (with-current-buffer buffer
           (save-restriction
             (widen)
-            (goto-line (nth 1 frame))
-           (forward-line 0)
+            (goto-char (point-min))
+            (forward-line (1- (nth 1 frame)))
             (setq pos (point))
            (setq idlwave-shell-is-stopped t)
 
@@ -2401,7 +2369,7 @@ matter what the settings of that variable."
                                    idlwave-shell-electric-stop-line-face
                                  idlwave-shell-stop-line-face))
                  (move-overlay idlwave-shell-stop-line-overlay
-                               (point) (save-excursion (end-of-line) (point))
+                               (point) (point-at-eol)
                                (current-buffer)))
              ;; use the arrow instead, but only if marking is wanted.
              (if idlwave-shell-mark-stop-line
@@ -2448,7 +2416,8 @@ matter what the settings of that variable."
 
 
 (defun idlwave-shell-step (arg)
-  "Step one source line. If given prefix argument ARG, step ARG source lines."
+  "Step one source line.
+If given prefix argument ARG, step ARG source lines."
   (interactive "p")
   (or (not arg) (< arg 1)
       (setq arg 1))
@@ -2473,14 +2442,14 @@ Uses IDL's stepover executive command which does not enter called functions."
                                           no-show)
   "Set breakpoint at current line.
 
-If Count is nil then an ordinary breakpoint is set.  We treat a count
+If COUNT is nil then an ordinary breakpoint is set.  We treat a COUNT
 of 1 as a temporary breakpoint using the ONCE keyword.  Counts greater
 than 1 use the IDL AFTER=count keyword to break only after reaching
-the statement count times.
+the statement COUNT times.
 
 Optional argument CMD is a list or function to evaluate upon reaching
 the breakpoint.  CONDITION is a break condition, and DISABLED, if
-non-nil disables the breakpoint"
+non-nil disables the breakpoint."
   (interactive "P")
   (when (listp count)
     (if (equal (car count) 4)
@@ -2593,9 +2562,7 @@ If in the IDL shell buffer, returns `idlwave-shell-pc-frame'."
     (list (idlwave-shell-file-name (buffer-file-name))
           (save-restriction
             (widen)
-            (save-excursion
-              (beginning-of-line)
-              (1+ (count-lines 1 (point))))))))
+           (1+ (count-lines 1 (point-at-bol)))))))
 
 (defun idlwave-shell-current-module ()
   "Return the name of the module for the current file.
@@ -2615,8 +2582,8 @@ Returns nil if unable to obtain a module name."
 
 (defun idlwave-shell-clear-current-bp ()
   "Remove breakpoint at current line.
-This command can be called from the shell buffer if IDL is currently stopped
-at a breakpoint."
+This command can be called from the shell buffer if IDL is currently
+stopped at a breakpoint."
   (interactive)
   (let ((bp (idlwave-shell-find-current-bp)))
     (if bp (idlwave-shell-clear-bp bp))))
@@ -2691,8 +2658,8 @@ in the current routine."
 
 
 (defun idlwave-shell-set-bp-in-module (name type class)
-  "Set breakpoint in module.  Assumes that `idlwave-shell-sources-alist'
-contains an entry for that module."
+  "Set breakpoint in module.
+Assumes that `idlwave-shell-sources-alist' contains an entry for that module."
   (let* ((module (idlwave-make-full-name class name))
         (source-file
          (car-safe (cdr-safe
@@ -2711,8 +2678,7 @@ contains an entry for that module."
          (message "The source file for module %s is probably not compiled"
                   module)
          (beep))
-      (save-excursion
-       (set-buffer buf)
+      (with-current-buffer buf
        (save-excursion
          (goto-char (point-min))
          (let ((case-fold-search t))
@@ -2789,7 +2755,8 @@ Runs to the last statement and then steps 1 statement.  Use the .out command."
             (or (not bp-line) (funcall closer-func cur-line bp-line)))
            (setq bp-line cur-line))))
     (unless bp-line (error "No further breakpoints"))
-    (goto-line bp-line)))
+    (goto-char (point-min))
+    (forward-line (1- bp-line))))
 
 ;; Examine Commands ------------------------------------------------------
 
@@ -2819,8 +2786,8 @@ Runs to the last statement and then steps 1 statement.  Use the .out command."
        (idlwave-shell-print (if (idlwave-region-active-p) '(4) nil)
                            ,help ,ev))))
 
-;;; Begin terrible hack section -- XEmacs tests for button2 explicitly
-;;; on drag events, calling drag-n-drop code if detected.  Ughhh...
+;; Begin terrible hack section -- XEmacs tests for button2 explicitly
+;; on drag events, calling drag-n-drop code if detected.  Ughhh...
 (defun idlwave-default-mouse-track-event-is-with-button (event n)
   t)
 
@@ -2837,17 +2804,17 @@ Runs to the last statement and then steps 1 statement.  Use the .out command."
 ;;; End terrible hack section
 
 (defun idlwave-shell-mouse-print (event)
-  "Print value of variable at the mouse position, with `help'"
+  "Print value of variable at the mouse position, with `print'."
   (interactive "e")
   (funcall (idlwave-shell-mouse-examine nil) event))
 
 (defun idlwave-shell-mouse-help (event)
-  "Print value of variable at the mouse position, with `print'."
+  "Print value of variable at the mouse position, with `help'."
   (interactive "e")
   (funcall (idlwave-shell-mouse-examine 'help) event))
 
 (defun idlwave-shell-examine-select (event)
-  "Pop-up a list to select from for examining the expression"
+  "Pop-up a list to select from for examining the expression."
   (interactive "e")
   (funcall (idlwave-shell-mouse-examine nil event) event))
 
@@ -2878,7 +2845,7 @@ An expression is an identifier plus 1 pair of matched parentheses
 directly following the identifier - an array or function call.
 Alternatively, an expression is the contents of any matched
 parentheses when the open parenthesis is not directly preceded by an
-identifier. If point is at the beginning or within an expression
+identifier.  If point is at the beginning or within an expression
 return the inner-most containing expression, otherwise, return the
 preceding expression.
 
@@ -2888,9 +2855,9 @@ use the current region as the expression.
 With double prefix arg ARG prompt for an expression.
 
 If EV is a valid event passed, pop-up a list from
-idlw-shell-examine-alist from which to select the help command text.
-If instead COMPLETE-HELP-TYPE is non-nil, choose from
-idlw-shell-examine-alist via mini-buffer shortcut key."
+`idlwave-shell-examine-alist' from which to select the help
+command text.  If instead COMPLETE-HELP-TYPE is non-nil, choose
+from `idlwave-shell-examine-alist' via mini-buffer shortcut key."
   (interactive "P")
 
   ;; For speed: assume the helper routine hasn't been lost, e.g. with
@@ -2919,7 +2886,7 @@ idlw-shell-examine-alist via mini-buffer shortcut key."
         ;; Move to beginning of current or previous expression
         (if (looking-at "\\<\\|(")
             ;; At beginning of expression, don't move backwards unless
-            ;; this is at the end of an indentifier.
+            ;; this is at the end of an identifier.
             (if (looking-at "\\>")
                 (backward-sexp))
           (backward-sexp))
@@ -3032,8 +2999,7 @@ idlw-shell-examine-alist via mini-buffer shortcut key."
 (defun idlwave-shell-examine-display ()
   "View the examine command output in a separate buffer."
   (let (win cur-beg cur-end)
-    (save-excursion
-      (set-buffer (get-buffer-create "*Examine*"))
+    (with-current-buffer (get-buffer-create "*Examine*")
       (use-local-map idlwave-shell-examine-map)
       (setq buffer-read-only nil)
       (goto-char (point-max))
@@ -3118,13 +3084,11 @@ idlw-shell-examine-alist via mini-buffer shortcut key."
 
 (defun idlwave-shell-examine-display-clear ()
   (interactive)
-  (save-excursion
-    (let ((buf (get-buffer "*Examine*")))
-      (when (bufferp buf)
-       (set-buffer buf)
-       (setq buffer-read-only nil)
-       (erase-buffer)
-       (setq buffer-read-only t)))))
+  (let ((buf (get-buffer "*Examine*")))
+    (when (bufferp buf)
+      (with-current-buffer buf
+       (let ((inhibit-read-only t))
+          (erase-buffer))))))
 
 (defun idlwave-retrieve-expression-from-level (expr level)
   "Return IDL command to print the expression EXPR from stack level LEVEL.
@@ -3219,8 +3183,7 @@ size(___,/DIMENSIONS)"
         (process (get-buffer-process buffer))
         (process-mark (if process (process-mark process)))
         output-begin output-end)
-    (save-excursion
-      (set-buffer buffer)
+    (with-current-buffer buffer
       (goto-char process-mark)
       (beginning-of-line)
       (setq output-end (point))
@@ -3269,7 +3232,7 @@ Remaining elements of the cdr:
 data - Data associated with the breakpoint by idlwave-shell currently
 contains four items:
 
-count - number of times to execute breakpoint. When count reaches 0
+count - number of times to execute breakpoint.  When count reaches 0
   the breakpoint is cleared and removed from the alist.
 
 command - command to execute when breakpoint is reached, either a
@@ -3278,23 +3241,22 @@ command - command to execute when breakpoint is reached, either a
 
 condition - any condition to apply to the breakpoint.
 
-disabled - whether the bp is disabled")
+disabled - whether the bp is disabled.")
 
 (defun idlwave-shell-run-region (beg end &optional n)
   "Compile and run the region using the IDL process.
 Copies the region to a temporary file `idlwave-shell-temp-pro-file'
-and issues the IDL .run command for the file.  Because the
-region is compiled and run as a main program there is no
-problem with begin-end blocks extending over multiple
-lines - which would be a problem if `idlwave-shell-evaluate-region'
-was used.  An END statement is appended to the region if necessary.
+and issues the IDL .run command for the file.  Because the region
+is compiled and run as a main program there is no problem with
+begin-end blocks extending over multiple lines - which would be
+a problem if `idlwave-shell-evaluate-region' was used.
+An END statement is appended to the region if necessary.
 
 If there is a prefix argument, display IDL process."
   (interactive "r\nP")
   (let ((oldbuf (current-buffer)))
-    (save-excursion
-      (set-buffer (idlwave-find-file-noselect
-                  (idlwave-shell-temp-file 'pro) 'tmp))
+    (with-current-buffer (idlwave-find-file-noselect
+                          (idlwave-shell-temp-file 'pro) 'tmp)
       (set (make-local-variable 'comment-start-skip) ";+[ \t]*")
       (set (make-local-variable 'comment-start) ";")
       (erase-buffer)
@@ -3376,12 +3338,12 @@ Queries IDL using the string in `idlwave-shell-bp-query'."
                              'hide))
 
 (defun idlwave-shell-bp-get (bp &optional item)
-  "Get a value for a breakpoint.  BP has the form of elements in
-idlwave-shell-bp-alist.  Optional second arg ITEM is the
-particular value to retrieve.  ITEM can be 'file, 'line, 'index,
-'module, 'count, 'cmd, 'condition, 'disabled, 'type, or
-'data.  'data returns a list of 'count, 'cmd and 'condition.
-Defaults to 'index."
+  "Get a value for a breakpoint.
+BP has the form of elements in `idlwave-shell-bp-alist'.
+Optional second arg ITEM is the particular value to retrieve.
+ITEM can be 'file, 'line, 'index, 'module, 'count, 'cmd,
+'condition, 'disabled, 'type, or 'data.  'data returns a list
+of 'count, 'cmd and 'condition.  Defaults to 'index."
   (cond
    ;; Frame
    ((eq item 'line) (nth 1 (car bp)))
@@ -3403,12 +3365,11 @@ Defaults to 'index."
    (t (nth 0 (car (cdr bp))))))
 
 (defun idlwave-shell-filter-bp (&optional no-show)
-  "Get the breakpoints from `idlwave-shell-command-output'.  Create
-`idlwave-shell-bp-alist' updating breakpoint count and command data
-from previous breakpoint list.  If NO-SHOW is set, don't update the
-breakpoint overlays."
-  (save-excursion
-    (set-buffer (get-buffer-create idlwave-shell-bp-buffer))
+  "Get the breakpoints from `idlwave-shell-command-output'.
+Create `idlwave-shell-bp-alist' updating breakpoint count and command
+data from previous breakpoint list.  If NO-SHOW is set, don't update
+the breakpoint overlays."
+  (with-current-buffer (get-buffer-create idlwave-shell-bp-buffer)
     (erase-buffer)
     (insert idlwave-shell-command-output)
     (goto-char (point-min))
@@ -3487,10 +3448,11 @@ If BP frame is in `idlwave-shell-bp-alist' updates the breakpoint data."
   (setcdr (cdr bp) data))
 
 (defun idlwave-shell-bp (frame &optional data module)
-  "Create a breakpoint structure containing FRAME and DATA.  Second
-and third args, DATA and MODULE, are optional.  Returns a breakpoint
-of the format used in `idlwave-shell-bp-alist'.  Can be used in commands
-attempting match a breakpoint in `idlwave-shell-bp-alist'."
+  "Create a breakpoint structure containing FRAME and DATA.
+Second and third args, DATA and MODULE, are optional.  Returns
+a breakpoint of the format used in `idlwave-shell-bp-alist'.
+Can be used in commands attempting match a breakpoint in
+`idlwave-shell-bp-alist'."
   (cons frame ;; (file line)
        (cons (list nil module) ;; (index_id (module type) | module)
              data)))           ;; (count command condition disabled)
@@ -3501,7 +3463,7 @@ attempting match a breakpoint in `idlwave-shell-bp-alist'."
 (defun idlwave-shell-sources-bp (bp)
   "Check `idlwave-shell-sources-alist' for source of breakpoint using BP.
 If an equivalency is found, return the IDL internal source name.
-Otherwise return the filename in bp."
+Otherwise return the filename in BP."
   (let*
       ((bp-file (idlwave-shell-bp-get bp 'file))
        (bp-module (idlwave-shell-bp-get bp 'module))
@@ -3619,7 +3581,7 @@ considered the new breakpoint if the file name of frame matches."
       (message "Failed to identify breakpoint in IDL"))))
 
 (defvar idlwave-shell-bp-overlays nil
-  "Alist of overlays marking breakpoints")
+  "Alist of overlays marking breakpoints.")
 (defvar idlwave-shell-bp-glyph)
 
 (defvar idlwave-shell-debug-line-map (make-sparse-keymap))
@@ -3652,7 +3614,7 @@ Existing overlays are recycled, in order to minimize consumption."
       (while (setq bp (pop bp-list))
        (save-excursion
          (idlwave-shell-goto-frame (car bp))
-         (let* ((end (progn (end-of-line 1) (point)))
+         (let* ((end (point-at-eol))
                 (beg (progn (beginning-of-line 1) (point)))
                 (condition (idlwave-shell-bp-get bp 'condition))
                 (count (idlwave-shell-bp-get bp 'count))
@@ -3728,7 +3690,7 @@ Existing overlays are recycled, in order to minimize consumption."
 (defun idlwave-shell-make-new-bp-overlay (&optional type disabled)
   "Make a new overlay for highlighting breakpoints.
 
-This stuff is strongly dependant upon the version of Emacs.  If TYPE
+This stuff is strongly dependent upon the version of Emacs.  If TYPE
 is passed, make an overlay of that type ('bp or 'bp-cond, currently
 only for glyphs)."
   (let ((ov (make-overlay 1 1))
@@ -3904,14 +3866,13 @@ handled by this command."
   (setq overlay-arrow-string nil)
   (let (buf)
     (cond
-     ((eq major-mode 'idlwave-mode)
+     ((derived-mode-p 'idlwave-mode)
       (save-buffer)
       (setq idlwave-shell-last-save-and-action-file (buffer-file-name)))
      (idlwave-shell-last-save-and-action-file
       (if (setq buf (idlwave-get-buffer-visiting
                     idlwave-shell-last-save-and-action-file))
-         (save-excursion
-           (set-buffer buf)
+         (with-current-buffer buf
            (save-buffer))))
      (t (setq idlwave-shell-last-save-and-action-file
              (read-file-name "File: ")))))
@@ -3950,7 +3911,7 @@ handled by this command."
   "Alist of IDL procedure names and compiled source files.
 Elements of the alist have the form:
 
-  (module name . (source-file-truename idlwave-internal-filename)).")
+  (module name . (source-file-truename idlwave-internal-filename))")
 
 (defun idlwave-shell-module-source-query (module &optional type)
   "Determine the source file for a given module.
@@ -3963,7 +3924,7 @@ Query as a function if TYPE set to something beside 'pro."
        'hide 'wait)))
 
 (defun idlwave-shell-module-source-filter (module)
-  "Get module source, and update idlwave-shell-sources-alist."
+  "Get module source, and update `idlwave-shell-sources-alist'."
   (let ((old (assoc (upcase module) idlwave-shell-sources-alist))
        filename)
     (when (string-match "\.PATH *[\n\r]\\([^%][^\r\n]+\\)[\n\r]"
@@ -3988,11 +3949,10 @@ Queries IDL using the string in `idlwave-shell-sources-query'."
 
 (defun idlwave-shell-sources-filter ()
   "Get source files from `idlwave-shell-sources-query' output.
-Create `idlwave-shell-sources-alist' consisting of
-list elements of the form:
- (module name . (source-file-truename idlwave-internal-filename))."
-  (save-excursion
-    (set-buffer (get-buffer-create idlwave-shell-bp-buffer))
+Create `idlwave-shell-sources-alist' consisting of list elements
+of the form:
+ (module name . (source-file-truename idlwave-internal-filename))"
+  (with-current-buffer (get-buffer-create idlwave-shell-bp-buffer)
     (erase-buffer)
     (insert idlwave-shell-command-output)
     (goto-char (point-min))
@@ -4008,8 +3968,7 @@ list elements of the form:
                   (append
                    ;; compiled procedures
                    (progn
-                     (beginning-of-line)
-                     (narrow-to-region cpro (point))
+                     (narrow-to-region cpro (point-at-bol))
                      (goto-char (point-min))
                      (idlwave-shell-sources-grep))
                    ;; compiled functions
@@ -4064,8 +4023,7 @@ list elements of the form:
   "Move point to next IDL syntax error."
   (interactive)
   (let (frame col)
-    (save-excursion
-      (set-buffer idlwave-shell-error-buffer)
+    (with-current-buffer idlwave-shell-error-buffer
       (goto-char idlwave-shell-error-last)
       (if (or
           (re-search-forward idlwave-shell-syntax-error nil t)
@@ -4096,7 +4054,7 @@ list elements of the form:
 (defun idlwave-shell-file-name (name)
   "If `idlwave-shell-use-truename' is non-nil, convert file name to true name.
 Otherwise, just expand the file name."
-  (let ((def-dir (if (eq major-mode 'idlwave-shell-mode)
+  (let ((def-dir (if (derived-mode-p 'idlwave-shell-mode)
                     default-directory
                   idlwave-shell-default-directory)))
     (if idlwave-shell-use-truename
@@ -4106,7 +4064,7 @@ Otherwise, just expand the file name."
 ;; Keybindings ------------------------------------------------------------
 
 (defvar idlwave-shell-mode-map (copy-keymap comint-mode-map)
-  "Keymap for idlwave-mode.")
+  "Keymap for `idlwave-mode'.")
 (defvar idlwave-shell-electric-debug-mode-map (make-sparse-keymap))
 (defvar idlwave-shell-mode-prefix-map (make-sparse-keymap))
 (fset 'idlwave-shell-mode-prefix-map idlwave-shell-mode-prefix-map)
@@ -4223,12 +4181,8 @@ Otherwise, just expand the file name."
          ([(        ?[)]   ?[   idlwave-shell-goto-previous-bp t t)
          ([(        ?])]   ?]   idlwave-shell-goto-next-bp t t)
          ([(control ?f)]   ?f   idlwave-shell-window)))
-       (mod (cond ((and idlwave-shell-debug-modifiers
-                       (listp idlwave-shell-debug-modifiers)
-                       (not (equal '() idlwave-shell-debug-modifiers)))
-                  idlwave-shell-debug-modifiers)
-                 (idlwave-shell-activate-alt-keybindings
-                  '(alt))))
+       (mod (and (listp idlwave-shell-debug-modifiers)
+                idlwave-shell-debug-modifiers))
        (shift (memq 'shift mod))
        (mod-noshift (delete 'shift (copy-sequence mod)))
        s k1 c2 k2 cmd electric only-buffer cannotshift)
@@ -4268,15 +4222,15 @@ Otherwise, just expand the file name."
 (define-key idlwave-shell-electric-debug-mode-map "_"
   'idlwave-shell-stack-down)
 (define-key idlwave-shell-electric-debug-mode-map "e"
-  '(lambda () (interactive) (idlwave-shell-print '(16))))
+  (lambda () (interactive) (idlwave-shell-print '(16))))
 (define-key idlwave-shell-electric-debug-mode-map "q" 'idlwave-shell-retall)
 (define-key idlwave-shell-electric-debug-mode-map "t"
-  '(lambda () (interactive) (idlwave-shell-send-command "help,/TRACE")))
+  (lambda () (interactive) (idlwave-shell-send-command "help,/TRACE")))
 (define-key idlwave-shell-electric-debug-mode-map [(control ??)]
   'idlwave-shell-electric-debug-help)
 (define-key idlwave-shell-electric-debug-mode-map "x"
-  '(lambda (arg) (interactive "P")
-     (idlwave-shell-print arg nil nil t)))
+  (lambda (arg) (interactive "P")
+    (idlwave-shell-print arg nil nil t)))
 
 
 ; Enter the prefix map in two places.
@@ -4302,16 +4256,14 @@ Otherwise, just expand the file name."
 (defvar idlwave-shell-electric-debug-buffers nil)
 
 (define-minor-mode idlwave-shell-electric-debug-mode
-  "Toggle Electric Debug mode.
-With no argument, this command toggles the mode.
-Non-null prefix argument turns on the mode.
-Null prefix argument turns off the mode.
+  "Toggle Idlwave Shell Electric Debug mode.
+With a prefix argument ARG, enable the mode if ARG is positive,
+and disable it otherwise.  If called from Lisp, enable the mode
+if ARG is omitted or nil.
 
-When Electric Debug mode is enabled, the many debugging commands are
-available as single key sequences."
-nil
-" *Debugging*"
-idlwave-shell-electric-debug-mode-map)
+When Idlwave Shell Electric Debug mode is enabled, the Idlwave
+Shell debugging commands are available as single key sequences."
+  nil " *Debugging*" idlwave-shell-electric-debug-mode-map)
 
 (add-hook
  'idlwave-shell-electric-debug-mode-on-hook
@@ -4343,7 +4295,7 @@ idlwave-shell-electric-debug-mode-map)
 
 ;; easy-mmode defines electric-debug-mode for us, so we need to advise it.
 (defadvice idlwave-shell-electric-debug-mode (after print-enter activate)
-  "Print out an entrance message"
+  "Print out an entrance message."
   (when idlwave-shell-electric-debug-mode
     (message
      "Electric Debugging mode entered.  Press [C-?] for help, [q] to quit"))
@@ -4359,7 +4311,7 @@ idlwave-shell-electric-debug-mode-map)
       (while (setq buf (pop buffers))
        (when (buffer-live-p buf)
          (set-buffer buf)
-         (when (and (eq major-mode 'idlwave-mode)
+         (when (and (derived-mode-p 'idlwave-mode)
                     buffer-file-name
                     idlwave-shell-electric-debug-mode)
            (idlwave-shell-electric-debug-mode 0))))))
@@ -4384,51 +4336,51 @@ idlwave-shell-electric-debug-mode-map)
     ["Electric Debug Mode"
      idlwave-shell-electric-debug-mode
      :style toggle :selected idlwave-shell-electric-debug-mode
-     :included (eq major-mode 'idlwave-mode) :keys "C-c C-d C-v"]
+     :included (derived-mode-p 'idlwave-mode) :keys "C-c C-d C-v"]
     "--"
     ("Compile & Run"
      ["Save and .RUN" idlwave-shell-save-and-run
-      (or (eq major-mode 'idlwave-mode)
+      (or (derived-mode-p 'idlwave-mode)
          idlwave-shell-last-save-and-action-file)]
      ["Save and .COMPILE" idlwave-shell-save-and-compile
-      (or (eq major-mode 'idlwave-mode)
+      (or (derived-mode-p 'idlwave-mode)
          idlwave-shell-last-save-and-action-file)]
      ["Save and @Batch" idlwave-shell-save-and-batch
-      (or (eq major-mode 'idlwave-mode)
+      (or (derived-mode-p 'idlwave-mode)
          idlwave-shell-last-save-and-action-file)]
      "--"
      ["Goto Next Error" idlwave-shell-goto-next-error t]
      "--"
      ["Compile and Run Region" idlwave-shell-run-region
-      (eq major-mode 'idlwave-mode)]
+      (derived-mode-p 'idlwave-mode)]
      ["Evaluate Region" idlwave-shell-evaluate-region
-      (eq major-mode 'idlwave-mode)]
+      (derived-mode-p 'idlwave-mode)]
      "--"
      ["Execute Default Cmd" idlwave-shell-execute-default-command-line t]
      ["Edit Default Cmd" idlwave-shell-edit-default-command-line t])
     ("Breakpoints"
      ["Set Breakpoint" idlwave-shell-break-here
-      :keys "C-c C-d C-b" :active (eq major-mode 'idlwave-mode)]
+      :keys "C-c C-d C-b" :active (derived-mode-p 'idlwave-mode)]
      ("Set Special Breakpoint"
       ["Set After Count Breakpoint"
        (progn
        (let ((count (string-to-number (read-string "Break after count: "))))
              (if (integerp count) (idlwave-shell-break-here count))))
-       :active (eq major-mode 'idlwave-mode)]
+       :active (derived-mode-p 'idlwave-mode)]
       ["Set Condition Breakpoint"
        (idlwave-shell-break-here '(4))
-       :active (eq major-mode 'idlwave-mode)])
+       :active (derived-mode-p 'idlwave-mode)])
      ["Break in Module" idlwave-shell-break-in
-      :keys "C-c C-d C-i" :active (eq major-mode 'idlwave-mode)]
+      :keys "C-c C-d C-i" :active (derived-mode-p 'idlwave-mode)]
      ["Break in this Module" idlwave-shell-break-this-module
-      :keys "C-c C-d C-j" :active (eq major-mode 'idlwave-mode)]
+      :keys "C-c C-d C-j" :active (derived-mode-p 'idlwave-mode)]
      ["Clear Breakpoint" idlwave-shell-clear-current-bp t]
      ["Clear All Breakpoints" idlwave-shell-clear-all-bp t]
      ["Disable/Enable Breakpoint" idlwave-shell-toggle-enable-current-bp t]
      ["Goto Previous Breakpoint" idlwave-shell-goto-previous-bp
-      :keys "C-c C-d [" :active (eq major-mode 'idlwave-mode)]
+      :keys "C-c C-d [" :active (derived-mode-p 'idlwave-mode)]
      ["Goto Next Breakpoint" idlwave-shell-goto-next-bp
-      :keys "C-c C-d ]" :active (eq major-mode 'idlwave-mode)]
+      :keys "C-c C-d ]" :active (derived-mode-p 'idlwave-mode)]
      ["List All Breakpoints" idlwave-shell-list-all-bp t]
      ["Resync Breakpoints" idlwave-shell-bp-query t])
     ("Continue/Step"
@@ -4440,7 +4392,7 @@ idlwave-shell-electric-debug-mode-map)
      ["... to End of Subprog" idlwave-shell-return t]
      ["... to End of Subprog+1" idlwave-shell-out t]
      ["... to Here (Cursor Line)" idlwave-shell-to-here
-      :keys "C-c C-d C-h" :active (eq major-mode 'idlwave-mode)])
+      :keys "C-c C-d C-h" :active (derived-mode-p 'idlwave-mode)])
     ("Examine Expressions"
      ["Print expression" idlwave-shell-print t]
      ["Help on expression" idlwave-shell-help-expression t]
@@ -4522,14 +4474,13 @@ idlwave-shell-electric-debug-mode-map)
       (easy-menu-define
        idlwave-shell-mode-menu idlwave-shell-mode-map "IDL shell menus"
        idlwave-shell-menu-def)
-      (save-excursion
-       (mapc (lambda (buf)
-               (set-buffer buf)
-               (if (eq major-mode 'idlwave-mode)
-                   (progn
-                     (easy-menu-remove idlwave-mode-debug-menu)
-                     (easy-menu-add idlwave-mode-debug-menu))))
-             (buffer-list)))))
+      (save-current-buffer
+       (dolist (buf (buffer-list))
+          (set-buffer buf)
+          (if (derived-mode-p 'idlwave-mode)
+              (progn
+                (easy-menu-remove idlwave-mode-debug-menu)
+                (easy-menu-add idlwave-mode-debug-menu)))))))
 
 ;; The Breakpoint Glyph -------------------------------------------------------
 
@@ -4690,12 +4641,12 @@ static char * file[] = {
 (provide 'idlw-shell)
 (provide 'idlwave-shell)
 
-;;; Load the toolbar when wanted by the user.
+;; Load the toolbar when wanted by the user.
 
 (autoload 'idlwave-toolbar-toggle "idlw-toolbar"
-  "Toggle the IDLWAVE toolbar")
+  "Toggle the IDLWAVE toolbar.")
 (autoload 'idlwave-toolbar-add-everywhere "idlw-toolbar"
-  "Add IDLWAVE toolbar")
+  "Add IDLWAVE toolbar.")
 (defun idlwave-shell-toggle-toolbar ()
   "Toggle the display of the debugging toolbar."
   (interactive)
@@ -4704,5 +4655,4 @@ static char * file[] = {
 (if idlwave-shell-use-toolbar
     (add-hook 'idlwave-shell-mode-hook 'idlwave-toolbar-add-everywhere))
 
-;; arch-tag: 20c2e8ce-0709-41d8-a5b6-bb039148440a
 ;;; idlw-shell.el ends here