Merge from emacs-24; up to 2014-05-12T06:15:47Z!rgm@gnu.org
[bpt/emacs.git] / lisp / progmodes / idlwave.el
index 74f37df..86a1603 100644 (file)
@@ -1,6 +1,6 @@
 ;; idlwave.el --- IDL editing mode for GNU Emacs
 
-;; Copyright (C) 1999-201 Free Software Foundation, Inc.
+;; Copyright (C) 1999-2014 Free Software Foundation, Inc.
 
 ;; Authors: J.D. Smith <jdsmith@as.arizona.edu>
 ;;          Carsten Dominik <dominik@science.uva.nl>
@@ -27,7 +27,7 @@
 ;;; Commentary:
 
 ;; IDLWAVE enables feature-rich development and interaction with IDL,
-;; the Interactive Data Language. It provides a compelling,
+;; the Interactive Data Language.  It provides a compelling,
 ;; full-featured alternative to the IDLDE development environment
 ;; bundled with IDL.
 
@@ -51,7 +51,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-mode "idlwave" "IDLWAVE Mode" t)
 ;; (autoload 'idlwave-shell "idlw-shell" "IDLWAVE Shell" t)
@@ -381,7 +381,7 @@ current   Scan only the current buffer, but no other buffers."
   :type '(choice
          (const :tag "No buffer" nil)
          (const :tag "All buffers" t)
-         (const :tag "Current buffer only" 'current)))
+         (const :tag "Current buffer only" current)))
 
 (defcustom idlwave-query-shell-for-routine-info t
   "Non-nil means query the shell for info about compiled routines.
@@ -447,8 +447,9 @@ value of `!DIR'.  See also `idlwave-library-path'."
 
 ;; Configuration files
 (defcustom idlwave-config-directory
-  (convert-standard-filename "~/.idlwave")
+  (locate-user-emacs-file "idlwave" ".idlwave")
   "Directory for configuration files and user-library catalog."
+  :version "24.4"                      ; added locate-user-emacs-file
   :group 'idlwave-routine-info
   :type 'file)
 
@@ -456,9 +457,6 @@ value of `!DIR'.  See also `idlwave-library-path'."
 (defvar idlwave-xml-system-rinfo-converted-file "idl_xml_rinfo.el")
 (defvar idlwave-path-file "idlpath.el")
 
-(defvar idlwave-libinfo-file nil
-  "Obsolete variable, no longer used.")
-
 (defcustom idlwave-special-lib-alist nil
   "Alist of regular expressions matching special library directories.
 When listing routine source locations, IDLWAVE gives a short hint where
@@ -555,10 +553,6 @@ completions."
   :group 'idlwave-completion
   :type 'boolean)
 
-(defvar idlwave-default-completion-case-is-down nil
-  "Obsolete variable.  See `idlwave-complete-empty-string-as-lower-case' and
-`idlwave-completion-case'.")
-
 (defcustom idlwave-buffer-case-takes-precedence nil
   "Non-nil means, the case of tokens in buffers dominates over system stuff.
 To make this possible, we need to re-case everything each time we update
@@ -753,7 +747,7 @@ or even '?'.  '.' is not a good choice because it can make structure
 field names act like abbrevs in certain circumstances.
 
 Changes to this in `idlwave-mode-hook' will have no effect.  Instead a user
-must set it directly using `setq' in the .emacs file before idlwave.el
+must set it directly using `setq' in the init file before idlwave.el
 is loaded."
   :group 'idlwave-abbrev-and-indent-action
   :type 'string)
@@ -783,7 +777,7 @@ spaces are left unchanged."
   :type '(choice
          (const :tag "Pad like assignments" t)
          (const :tag "Remove space near `='" nil)
-         (const :tag "Keep space near `='" 'keep)))
+         (other :tag "Keep space near `='" keep)))
 
 (defcustom idlwave-show-block t
   "Non-nil means point blinks to block beginning for `idlwave-show-begin'."
@@ -1158,7 +1152,7 @@ As a user, you should not set this to t.")
        (common-blocks
        '("\\<\\(common\\)\\>[ \t]*\\(\\sw+\\)?[ \t]*,?"
          (1 font-lock-keyword-face)              ; "common"
-         (2 font-lock-reference-face nil t)      ; block name
+         (2 font-lock-constant-face nil t)      ; block name
          ("[ \t]*\\(\\sw+\\)[ ,]*"
           ;; Start with point after block name and comma
           (goto-char (match-end 0))  ; needed for XEmacs, could be nil
@@ -1176,20 +1170,20 @@ As a user, you should not set this to t.")
 
        ;; Labels
        (label
-       '("^[ \t]*\\([a-zA-Z]\\sw*:\\)" (1 font-lock-reference-face)))
+       '("^[ \t]*\\([a-zA-Z]\\sw*:\\)" (1 font-lock-constant-face)))
 
        ;; The goto statement and its label
        (goto
        '("\\(goto\\)[ \t]*,[ \t]*\\([a-zA-Z]\\sw*\\)"
          (1 font-lock-keyword-face)
-         (2 font-lock-reference-face)))
+         (2 font-lock-constant-face)))
 
        ;; Tags in structure definitions.  Note that this definition
        ;; actually collides with labels, so we have to use the same
        ;; face.  It also matches named subscript ranges,
        ;; e.g. vec{bottom:top].  No good way around this.
        (structtag
-       '("\\<\\([a-zA-Z][a-zA-Z0-9_]*:\\)[^:]" (1 font-lock-reference-face)))
+       '("\\<\\([a-zA-Z][a-zA-Z0-9_]*:\\)[^:]" (1 font-lock-constant-face)))
 
        ;; Structure names
        (structname
@@ -1202,7 +1196,7 @@ As a user, you should not set this to t.")
        ;; fontification.  Slow, use it only in fancy fontification.
        (keyword-parameters
        '("\\(,\\|[a-zA-Z0-9_](\\)[ \t]*\\(\\$[ \t]*\\(;.*\\)?\n\\([ \t]*\\(;.*\\)?\n\\)*[ \t]*\\)?\\(/[a-zA-Z_]\\sw*\\|[a-zA-Z_]\\sw*[ \t]*=\\)"
-         (6 font-lock-reference-face)))
+         (6 font-lock-constant-face)))
 
        ;; System variables start with a bang.
        (system-variables
@@ -4525,8 +4519,6 @@ information updated immediately, leave NO-CONCATENATE nil."
                   nil 'idlwave-load-rinfo-next-step)))
        (error nil))))
 
-(defvar idlwave-library-routines nil "Obsolete variable.")
-
 ;;------ XML Help routine info system
 (defun idlwave-load-system-routine-info ()
   ;; Load the system routine info from the cached routine info file,
@@ -5087,11 +5079,14 @@ Cache to disk for quick recovery."
   ;; The sequence here is important because earlier definitions shadow
   ;; later ones.  We assume that if things in the buffers are newer
   ;; then in the shell of the system, they are meant to be different.
-  (setcdr idlwave-last-system-routine-info-cons-cell
-         (append idlwave-buffer-routines
-                 idlwave-compiled-routines
-                 idlwave-library-catalog-routines
-                 idlwave-user-catalog-routines))
+  (let ((temp (append idlwave-buffer-routines
+                     idlwave-compiled-routines
+                     idlwave-library-catalog-routines
+                     idlwave-user-catalog-routines)))
+    ;; Not actually used for anything?
+    (if idlwave-last-system-routine-info-cons-cell
+       (setcdr idlwave-last-system-routine-info-cons-cell temp)
+      (setq idlwave-last-system-routine-info-cons-cell (cons temp nil))))
   (setq idlwave-class-alist nil)
 
   ;; Give a message with information about the number of routines we have.
@@ -5244,9 +5239,7 @@ Can run from `after-save-hook'."
          class
          (cond ((not (boundp 'idlwave-scanning-lib))
                 (list  'buffer (buffer-file-name)))
-;              ((string= (downcase
-;                         (file-name-sans-extension
-;                          (file-name-nondirectory (buffer-file-name))))
+;              ((string= (downcase (file-name-base))
 ;                        (downcase name))
 ;               (list 'lib))
 ;              (t (cons 'lib (file-name-nondirectory (buffer-file-name))))
@@ -5492,30 +5485,21 @@ directories and save the routine info.
     (message "Creating user catalog file...")
     (kill-buffer "*idlwave-scan.pro*")
     (kill-buffer (get-buffer-create "*IDLWAVE Widget*"))
-    (let ((font-lock-maximum-size 0)
-         (auto-mode-alist nil))
-      (find-file idlwave-user-catalog-file))
-    (if (and (boundp 'font-lock-mode)
-            font-lock-mode)
-       (font-lock-mode 0))
-    (erase-buffer)
-    (insert ";; IDLWAVE user catalog file\n")
-    (insert (format ";; Created %s\n\n" (current-time-string)))
-
-    ;; Define the routine info list
-    (insert "\n(setq idlwave-user-catalog-routines\n    '(")
-    (let ((standard-output (current-buffer)))
-      (mapc (lambda (x)
-             (insert "\n    ")
-             (prin1 x)
-             (goto-char (point-max)))
-           idlwave-user-catalog-routines))
-    (insert (format "))\n\n;;; %s ends here\n"
-                   (file-name-nondirectory idlwave-user-catalog-file)))
-    (goto-char (point-min))
-    ;; Save the buffer
-    (save-buffer 0)
-    (kill-buffer (current-buffer)))
+    (with-temp-buffer
+      (insert ";; IDLWAVE user catalog file\n")
+      (insert (format ";; Created %s\n\n" (current-time-string)))
+
+      ;; Define the routine info list
+      (insert "\n(setq idlwave-user-catalog-routines\n    '(")
+      (let ((standard-output (current-buffer)))
+       (mapc (lambda (x)
+               (insert "\n    ")
+               (prin1 x)
+               (goto-char (point-max)))
+             idlwave-user-catalog-routines))
+      (insert (format "))\n\n;;; %s ends here\n"
+                     (file-name-nondirectory idlwave-user-catalog-file)))
+      (write-region nil nil idlwave-user-catalog-file)))
   (message "Creating user catalog file...done")
   (message "Info for %d routines saved in %s"
           (length idlwave-user-catalog-routines)
@@ -5533,31 +5517,23 @@ directories and save the routine info.
 (defun idlwave-write-paths ()
   (interactive)
   (when (and idlwave-path-alist idlwave-system-directory)
-    (let ((font-lock-maximum-size 0)
-         (auto-mode-alist nil))
-      (find-file idlwave-path-file))
-    (if (and (boundp 'font-lock-mode)
-            font-lock-mode)
-       (font-lock-mode 0))
-    (erase-buffer)
-    (insert ";; IDLWAVE paths\n")
-    (insert (format ";; Created %s\n\n" (current-time-string)))
+    (with-temp-buffer
+      (insert ";; IDLWAVE paths\n")
+      (insert (format ";; Created %s\n\n" (current-time-string)))
     ;; Define the variable which knows the value of "!DIR"
-    (insert (format "\n(setq idlwave-system-directory \"%s\")\n"
-                   idlwave-system-directory))
-
-    ;; Define the variable which contains a list of all scanned directories
-    (insert "\n(setq idlwave-path-alist\n    '(")
-    (let ((standard-output (current-buffer)))
-      (mapc (lambda (x)
-             (insert "\n      ")
-             (prin1 x)
-             (goto-char (point-max)))
-           idlwave-path-alist))
-    (insert "))\n")
-    (save-buffer 0)
-    (kill-buffer (current-buffer))))
-
+      (insert (format "\n(setq idlwave-system-directory \"%s\")\n"
+                     idlwave-system-directory))
+
+      ;; Define the variable which contains a list of all scanned directories
+      (insert "\n(setq idlwave-path-alist\n    '(")
+      (let ((standard-output (current-buffer)))
+       (mapc (lambda (x)
+               (insert "\n      ")
+               (prin1 x)
+               (goto-char (point-max)))
+             idlwave-path-alist))
+      (insert "))\n")
+      (write-region nil nil idlwave-path-file))))
 
 (defun idlwave-expand-path (path &optional default-dir)
   ;; Expand parts of path starting with '+' recursively into directory list.
@@ -7194,7 +7170,7 @@ If these don't exist, a letter in the string is automatically selected."
 
 (defun idlwave-choose-completion (&rest args)
   "Choose the completion that point is in or next to."
-  (interactive)
+  (interactive (list last-nonmenu-event))
   (apply 'idlwave-choose 'choose-completion args))
 
 (defun idlwave-mouse-choose-completion (&rest args)
@@ -9066,7 +9042,7 @@ Assumes that point is at the beginning of the unit as found by
 ;; Here we hack func-menu.el in order to support this new mode.
 ;; The latest versions of func-menu.el already have this stuff in, so
 ;; we hack only if it is not already there.
-(when (fboundp 'eval-after-load)
+(when (featurep 'xemacs)
   (eval-after-load "func-menu"
     '(progn
        (or (assq 'idlwave-mode fume-function-name-regexp-alist)
@@ -9320,6 +9296,8 @@ This function was written since `list-abbrevs' looks terrible for IDLWAVE mode."
   (with-current-buffer "*Help*"
     (setq truncate-lines t)))
 
+(declare-function speedbar-add-supported-extension "speedbar" (extension))
+
 ;; Add .pro files to speedbar for support, if it's loaded
 (eval-after-load "speedbar" '(speedbar-add-supported-extension ".pro"))