branch: externals/idlwave commit fb7634fdcf5b068208844b3c9c140ed3c29b1ab4 Merge: 39e7ed969e 82d8ed93ca Author: JD Smith <jdtsm...@gmail.com> Commit: JD Smith <jdtsm...@gmail.com>
Merge branch 'develop' --- idlw-help.el | 6 ++++-- idlw-scan.el | 58 +++++++++++++++++++++++++++++++++++++++++++--------------- idlw-shell.el | 59 +++++++++++++++++++++++++++++++++++++++++++---------------- 3 files changed, 90 insertions(+), 33 deletions(-) diff --git a/idlw-help.el b/idlw-help.el index 76036cd1f5..aceb0fecec 100644 --- a/idlw-help.el +++ b/idlw-help.el @@ -200,7 +200,7 @@ It collects and prints the diagnostics messages." (cdr (assq (idlwave-sintern-sysvartag tag) (cdr (assq 'tags entry)))))) - (link (nth 1 (assq 'link entry)))) + (link (cdr (assq 'link entry)))) (if tag-target (setq link (idlwave-substitute-link-target link tag-target))) @@ -305,6 +305,7 @@ It collects and prints the diagnostics messages." ;; Everything else (t (setq mod1 (append (list t) module)))) + (if mod3 (condition-case nil (apply 'idlwave-online-help mod1) @@ -582,7 +583,8 @@ see if a link is set for it. Try extra help functions if necessary." ;; If possible, subsume as anchor under idl.htm, new as of IDL 8.3 (if (file-exists-p alternate) - (setq help-loc (concat alternate "#"))) + (setq link (file-relative-name link help-loc) + help-loc (concat alternate "#"))) (setq full-link (browse-url-file-url (concat help-loc link))) diff --git a/idlw-scan.el b/idlw-scan.el index 00e6907b4d..c9d627bf56 100644 --- a/idlw-scan.el +++ b/idlw-scan.el @@ -1,5 +1,6 @@ ;; IDLWAVE: scan routine information provided with IDL, and among the -;; user's library, as well as open buffers +;; user's library, as well as in open buffers (for scanning the shell, +;; see idlw-shell.el) (require 'timer) @@ -745,9 +746,10 @@ Cache to disk for quick recovery." (defun idlwave-alias-path (file alias-list content-path &optional class-dir) "Search for the HTML help file FILE in the help content. Uses alias information ALIAS-LIST from Alias.xml to link to the -help content, in top level CONTENT-PATH. CLASS-DIR, is set is +help content, in top level CONTENT-PATH. CLASS-DIR, if set, is the directory of the class of a routine to try if it can't be -found through other means." +found through other means. As a last resort attempt a brute +force directory search." (let (alias linkfile) (if (and file (> (length file) 0)) (cond @@ -788,7 +790,8 @@ found through other means." ;; Dir from root name alias (e.g. CLASS_METHOD.html -> CLASS.html) ((let ((lfroot - (replace-regexp-in-string "_+[^_]*\.html" ".html" file))) + (replace-regexp-in-string + "_+[^_]*\.htm\\(l?\\)" ".htm\\1" file))) (and (not (string= file lfroot)) (setq alias (assoc-ignore-case lfroot alias-list)) (file-exists-p @@ -801,7 +804,10 @@ found through other means." ;; Didn't find it... try a brute-force directory search (t (message "searching for %s" file) - (if (setq linkfile (idlwave-recursive-find-file content-path file)) + (if (setq linkfile + (idlwave-recursive-find-file + content-path + (replace-regexp-in-string "\.html$" ".htm" file))) (progn (setq linkfile (file-relative-name linkfile content-path)) ;; Save it as an alias in case it is requested again @@ -809,6 +815,7 @@ found through other means." (prog1 nil (message "Could not locate %s" file)))))) linkfile)) + (defun idlwave-convert-xml-add-link-path-information () ;; Add path information missing from idl_catalog.xml since IDL 8 (let* ((help-path (expand-file-name "help/online_help/IDL/" @@ -824,9 +831,10 @@ found through other means." aliases (cdr aliases)) (when (and (listp elem) (eq (car elem) 'Map)) (setq elem (cadr elem)) - (let* ((link (cdr (assoc 'Link elem))) + (let* ((link (car (idlwave-split-link-target + (cdr (assoc 'Link elem))))) (file (file-name-nondirectory link))) - (push (cons file link) alias-list)))) + (add-to-list 'alias-list (cons file link))))) ;; System class info (mapc @@ -841,19 +849,23 @@ found through other means." (mapc (lambda (x) (let ((class (nth 2 x)) - (kwd_blocks (nthcdr 5 x)) link linkfile class-entry) + (kwd_blocks (nthcdr 5 x)) + link linkfile class-entry) (while kwd_blocks (setq link (car kwd_blocks) kwd_blocks (cdr kwd_blocks)) - (when (setq linkfile - (idlwave-alias-path + (when (and + (car link) + (string-match "\.htm\[^.\]*$" (car link)) + (setq linkfile + (idlwave-alias-path (car link) alias-list content-path (if (and class - (setq class-entry - (assoc class + (setq class-entry + (assoc class idlwave-system-class-info))) (file-name-directory - (nth 1 (assq 'link class-entry)))))) + (nth 1 (assq 'link class-entry))))))) (setcar link linkfile))))) idlwave-system-routines) @@ -864,7 +876,22 @@ found through other means." (if alias (setcdr x (cdr alias))))) (append idlwave-help-special-topic-words - idlwave-executive-commands-alist)))) + idlwave-executive-commands-alist)) + + ;; System variables + (mapc + (lambda (x) + (let* (linkfile + linkparts + (linkcell (assq 'link x)) + (link (cadr linkcell))) + (if (setq linkparts (idlwave-split-link-target link)) + (setq link (car linkparts))) + (if (setq linkfile + (idlwave-alias-path link alias-list content-path)) + (setcdr linkcell (idlwave-substitute-link-target + linkfile (cdr linkparts)))))) + idlwave-system-variables-alist))) (message "Linking help file info...done"))) (defun idlwave-convert-xml-clean-routine-aliases (aliases) @@ -1740,7 +1767,8 @@ end "Split a given LINK into link file and anchor." (if (and (stringp link) (string-match idlwave-html-link-sep link)) (cons (substring link 0 (match-beginning 0)) - (substring link (match-end 0))))) + (substring link (match-end 0))) + (list link))) (defun idlwave-substitute-link-target (link target) "Substitute the TARGET anchor for the given LINK." diff --git a/idlw-shell.el b/idlw-shell.el index 868c50d6f9..af6a270712 100644 --- a/idlw-shell.el +++ b/idlw-shell.el @@ -1085,13 +1085,13 @@ IDL has currently stepped.") (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 paging, and define a system ;; variable which knows the version of IDLWAVE + (idlwave-shell-send-command idlwave-shell-initial-commands nil 'hide 'wait) (idlwave-shell-send-command (format "!MORE=0 & defsysv,'!idlwave_version','%s',1" idlwave-mode-version) nil 'hide) + (run-mode-hooks 'idlwave-shell-mode-hook) ;; Read the paths, and save if they changed (idlwave-shell-send-command idlwave-shell-path-query 'idlwave-shell-get-path-info @@ -1155,7 +1155,7 @@ Will typically only apply if the buffer isn't visible." (setq idlwave-shell-display-wframe (if (eq (selected-frame) idlwave-shell-idl-wframe) (or - (let ((flist (visible-frame-list)) + (let ((flist (frames-on-display-list)) (frame (selected-frame))) (catch 'exit (while flist @@ -1385,10 +1385,10 @@ Disables line display after state scanning." '(progn (idlwave-shell-strip-input) (setq result idlwave-shell-command-output)) 'hide 'wait nil 'disable) - (with-current-buffer ;; DEBUGXXX - (get-buffer-create "*idlwave-shell-output*") - (goto-char (point-max)) - (insert (format "--[C.] New result: %s\n" result))) + ;; (with-current-buffer ;; DEBUGXXX + ;; (get-buffer-create "*idlwave-shell-output*") + ;; (goto-char (point-max)) + ;; (insert (format "--[C.] New result: %s\n" result))) result)) (defun idlwave-shell-send-char (c &optional error) @@ -2354,10 +2354,12 @@ overlays." "Display the source code one step up the calling stack." (interactive) (incf idlwave-shell-calling-stack-index) +; (message "scsi-up: %d" idlwave-shell-calling-stack-index) (idlwave-shell-display-level-in-calling-stack 'hide)) (defun idlwave-shell-stack-down () "Display the source code one step down the calling stack." (interactive) +; (message "scsi-down: %d" idlwave-shell-calling-stack-index) (decf idlwave-shell-calling-stack-index) (idlwave-shell-display-level-in-calling-stack 'hide)) @@ -2418,9 +2420,11 @@ matter what the settings of that variable." (if idlwave-shell-electric-debug-buffers (idlwave-shell-electric-debug-all-off))) (if (not (idlwave-shell-valid-frame frame)) - ;; 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)) + ;; fixme: errors are dangerous in shell filters. IDL LAMBDA + ;; functions are not stored as code, so just silently ignore + ;; these errors. + (unless (string-match-p "^IDL\$LAMBDA" (caddr frame)) + (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. @@ -3427,8 +3431,7 @@ Does not work for a region with multiline blocks - use "Display a buffer in a requested (optional) FRAME. Resize to no more than BUFFER-HEIGHT-FRAC of the frame buffer if set." (save-selected-window - (if frame (select-frame frame)) - (let ((win (display-buffer buf not-this-window-p t))) + (let ((win (display-buffer buf not-this-window-p frame))) (if buffer-height-frac (set-window-text-height win (round (* (frame-height frame) buffer-height-frac)))) @@ -3961,11 +3964,17 @@ one of the save-and-.. commands." (interactive) (idlwave-shell-save-and-action 'batch)) +(defvar idlwave-shell-master-file nil + "File local variable to compile instead of this file. +Useful for e.g. top level routines which @include others.") +(make-variable-buffer-local 'idlwave-shell-master-file) + (defun idlwave-shell-save-and-action (action) "Save file and compile it in IDL. -Runs `save-buffer' and sends a '.RUN' command for the associated file to IDL. -When called from the shell buffer, re-compile the file which was last -handled by this command." +Runs `save-buffer' and sends a '.RUN' command for the associated +file to IDL. When called from the shell buffer, re-compile the +file which was last handled by this command. If the +file-local-variable idlwave-shell-master-file is set, act on it instead." ;; Remove the stop overlay. (if idlwave-shell-stop-line-overlay (delete-overlay idlwave-shell-stop-line-overlay)) @@ -3977,7 +3986,11 @@ handled by this command." (cond ((eq major-mode 'idlwave-mode) (save-buffer) - (setq idlwave-shell-last-save-and-action-file (buffer-file-name))) + (setq idlwave-shell-last-save-and-action-file + (if idlwave-shell-master-file + (expand-file-name idlwave-shell-master-file + (file-name-directory (buffer-file-name))) + (buffer-file-name)))) (idlwave-shell-last-save-and-action-file (if (setq buf (idlwave-get-buffer-visiting idlwave-shell-last-save-and-action-file)) @@ -4004,6 +4017,18 @@ handled by this command." (setq idlwave-shell-last-save-and-action-file nil) (error msg)))) +(defun idlwave-shell-set-master-file () + "Set the master file locally for this file" + (interactive) + (if (eq major-mode 'idlwave-mode) + (let* ((master (read-file-name "Select IDL Master file: " nil nil t)) + (master-rel (file-relative-name + master + (file-name-directory (buffer-file-name))))) + (when (file-regular-p master) + (setq idlwave-shell-master-file master-rel) + (add-file-local-variable 'idlwave-shell-master-file master-rel))))) + (defun idlwave-shell-maybe-update-routine-info (&optional wait file) "Update the routine info if the shell is not stopped at an error." (if (and (not idlwave-shell-is-stopped) @@ -4585,6 +4610,8 @@ idlwave-shell-electric-debug-mode-map) 'idlwave-shell-get-path-info 'hide) t] + ["Set Master File" (idlwave-shell-set-master-file) + :active (eq major-mode 'idlwave-mode)] ["Reset IDL" idlwave-shell-reset t] "--" ["Toggle Toolbar" idlwave-shell-toggle-toolbar t]