Changeset aecc57 in git


Ignore:
Timestamp:
Aug 18, 1999, 8:40:44 PM (25 years ago)
Author:
Tim Wichmann <wichmann@…>
Branches:
(u'fieker-DuVal', '117eb8c30fc9e991c4decca4832b1d19036c4c65')(u'spielwiese', 'b4f17ed1d25f93d46dbe29e4b499baecc2fd51bb')
Children:
6af907a7a7d71fd3623a80d151ad4a95348ff2b5
Parents:
0853c9e725c01bb8b1db53a57f07174feac6762f
Message:
1999-08-18  T. Wichmann  <wichmann@arboretum.itwm.uni-kl.de>
        * singular.el singular-help-file-name variable introduced
	  added section for singular-*-alists
	  some defvars changed to defconsts
	  (singular-scan-header-exit) introduced
	  fancier calculation of singular-scan-header-scan-for
	  (singular-scan-header-got-emacs-home) introduced
	  singular-executable-default, ... are now defcustom
	  (singular-exit-sentinel) now call (singular-scan-header-exit)


git-svn-id: file:///usr/local/Singular/svn/trunk@3487 2c84dea3-7e68-4137-9b89-c4e89433aadc
File:
1 edited

Legend:

Unmodified
Added
Removed
  • emacs/singular.el

    r0853c9e raecc57  
    11;;; singular.el --- Emacs support for Computer Algebra System Singular
    22
    3 ;; $Id: singular.el,v 1.33 1999-08-18 06:40:21 wichmann Exp $
     3;; $Id: singular.el,v 1.34 1999-08-18 18:40:44 wichmann Exp $
    44
    55;;; Commentary:
     
    22532253  :group 'singular-interactive-miscellaneous)
    22542254
     2255(defvar singular-help-file-name nil
     2256  "File name of the Singular help file.
     2257This variable gets initialized in `singular-scan-header-init' and is set
     2258usually automatically by `singular-scan-header-pre-output-filter'. If set
     2259before evaluation of singular.el, the header of the first Singular will not
     2260be scanned for the help file name.
     2261
     2262This variable is buffer-local.")
     2263
    22552264(defvar singular-help-time-stamp 0
    22562265  "A time stamp set by `singular-help-pre-input-hook'.
     
    23812390;;}}}
    23822391
     2392;;{{{ Singular commands, help topics and standard libraries alists
     2393(defvar singular-commands-alist nil
     2394  "An alist containing all Singular commands to complete.
     2395
     2396This variable is buffer-local.")
     2397
     2398(defvar singular-help-topics-alist nil
     2399  "An alist containg all Singular help topics to complete.
     2400
     2401This variable is buffer-local.")
     2402
     2403(defvar singular-standard-libraries-alist nil
     2404  "An alist containing all Singular standard libraries names.
     2405
     2406This variable is buffer-local.")
     2407;;}}}
     2408
    23832409;;{{{ Scanning of header and handling of emacs home directory
    23842410;;
    23852411;; Scanning of header
    23862412;;
    2387 (defvar singular-scan-header-emacs-home-regexp "^// \\*\\* EmacsDir: \\(.+\\)\n"
     2413(defconst singular-scan-header-emacs-home-regexp "^// \\*\\* EmacsDir: \\(.+\\)\n"
    23882414  "Regular expression matching the location of emacs home in Singular
    23892415header.")
    23902416
    2391 (defvar singular-scan-header-info-file-regexp "^// \\*\\* InfoFile: \\(.+\\)\n"
     2417(defconst singular-scan-header-info-file-regexp "^// \\*\\* InfoFile: \\(.+\\)\n"
    23922418  "Regular expression matching the location of Singular info file in
    23932419Singular header.")
    23942420
    2395 (defvar singular-scan-header-time-stamp 0
     2421(defconst singular-scan-header-time-stamp 0
    23962422  "A time stamp set by singular-scan-header.
    23972423
    23982424This variable is buffer-local.")
    23992425
    2400 (defvar singular-scan-header-scan-for '(emacs-home info-file)
     2426(defvar singular-scan-header-scan-for '()
    24012427  "List of things to scan for in Singular header.
    24022428If `singular-scan-header-pre-output-filter' finds one thing in the current
     
    24042430If this variable gets nil, `singular-scan-header-pre-output-filter' is
    24052431removed from the pre-output-filter.
     2432This variable is initialized in `singular-scan-header-init'. Possible
     2433values of this list are up to now `help-file' and `emacs-home'.
    24062434
    24072435This variable is buffer-local.")
     2436
     2437(defun singular-scan-header-got-emacs-home ()
     2438  "Load Singular completion and libraries files.
     2439Assumes that `singular-emacs-home-directory' is set to the appropriate
     2440value and loads the files \"cmd-cmpl.el\", \"hlp-cmpl.el\", and
     2441\"lib-cmpl.el\".
     2442On success calls `singular-menu-install-libraries'."
     2443  (or (load (singular-expand-emacs-file-name "cmd-cmpl.el" t) t t t)
     2444      (message "Can't find command completion file! Command completion disabled."))
     2445  (or (load (singular-expand-emacs-file-name "hlp-cmpl.el" t) t t t)
     2446      (message "Can't find help topic completion file! Help completion disabled."))
     2447  (if (load (singular-expand-emacs-file-name "lib-cmpl.el" t) t t t)
     2448      (singular-menu-install-libraries)
     2449    (message "Can't find library index file!")))
     2450 
    24082451
    24092452(defun singular-scan-header-pre-output-filter (output)
     
    24212464    ;; Search for emacs home directory
    24222465    (when (string-match singular-scan-header-emacs-home-regexp output)
    2423       (singular-debug 'interactive
    2424                       (message "scan header: emacs home path found"))
    2425       (setq singular-scan-header-scan-for (delq 'emacs-home singular-scan-header-scan-for))
    2426       (setq singular-emacs-home-directory (substring output (match-beginning 1) (match-end 1)))
    2427       (setq output (replace-match "" t t output))
    2428       (setq changed t)
    2429 
    2430       (or (load (singular-expand-emacs-file-name "cmd-cmpl.el" t) t t t)
    2431           (message "Can't find command completion file! Command completion disabled."))
    2432       (or (load (singular-expand-emacs-file-name "hlp-cmpl.el" t) t t t)
    2433           (message "Can't find help topic completion file! Help completion disabled."))
    2434       (if (load (singular-expand-emacs-file-name "lib-cmpl.el" t) t t t)
    2435           (singular-menu-install-libraries)
    2436         (message "Can't find library index file!")))
     2466      (let ((emacs-home (substring output (match-beginning 1) (match-end 1))))
     2467        (singular-debug 'interactive
     2468                        (message "scan header: emacs home path found"))
     2469        ;; in any case, remove marker from output
     2470        (setq output (replace-match "" t t output))
     2471        (setq changed t)
     2472        ;; if not already done, do action an singular-emacs-home
     2473        (when (memq 'emacs-home singular-scan-header-scan-for)
     2474          (singular-debug 'interactive (message "scan header: initializing emacs-home-directory"))
     2475          (setq singular-scan-header-scan-for (delq 'emacs-home singular-scan-header-scan-for))
     2476          (setq singular-emacs-home-directory emacs-home)
     2477          (singular-scan-header-got-emacs-home))))
    24372478
    24382479    ;; Search for Singular info file
    24392480    (when (string-match singular-scan-header-info-file-regexp output)
    2440       (singular-debug 'interactive
    2441                       (message "scan header: singular.hlp path found"))
    2442       (setq singular-scan-header-scan-for (delq 'info-file singular-scan-header-scan-for))
    2443       (setq singular-help-file-name (substring output (match-beginning 1) (match-end 1)))
    2444       (setq output (replace-match "" t t output))
    2445       (setq changed t))
     2481      (let ((file-name (substring output (match-beginning 1) (match-end 1))))
     2482        (singular-debug 'interactive
     2483                        (message "scan header: singular.hlp path found"))
     2484        ;; in any case, remove marker from output
     2485        (setq output (replace-match "" t t output))
     2486        (setq changed t)
     2487        ;; if not already done, do action on help-file-name
     2488        (when (memq 'info-file singular-scan-header-scan-for)
     2489          (singular-debug 'interactive (message "scan header: initializing help-file-name"))
     2490          (setq singular-scan-header-scan-for (delq 'info-file singular-scan-header-scan-for))
     2491          (setq singular-help-file-name file-name))))
    24462492
    24472493    ;; Remove from hook if everything is found or if we already waited
     
    24602506  (singular-debug 'interactive (message "Initializing scan-header"))
    24612507  (set (make-local-variable 'singular-scan-header-time-stamp) (current-time))
    2462   (set (make-local-variable 'singular-emacs-home-directory) nil)
    2463   (set (make-local-variable 'singular-scan-header-scan-for) '(emacs-home info-file))
     2508  (set (make-local-variable 'singular-scan-header-scan-for) '())
     2509
     2510  (make-local-variable 'singular-emacs-home-directory)
     2511  ;; if singular-emacs-home is set try to load the completion files.
     2512  ;; Otherwise set marker that we still have to search for it.
     2513  (if singular-emacs-home-directory
     2514      (singular-scan-header-got-emacs-home)
     2515    (setq singular-scan-header-scan-for (append singular-scan-header-scan-for '(emacs-home))))
     2516
    24642517  ;; Up to now this seems to be the best place to initialize
    24652518  ;; `singular-help-file-name' since singular-help gets initialized
    24662519  ;; only on mode start-up, not on Singular start-up
    2467   (set (make-local-variable 'singular-help-file-name) nil)
     2520  ;;
     2521  ;; if singular-help-file-name is not set, mark, that we have to scan for it
     2522  (make-local-variable 'singular-help-file-name)
     2523  (or singular-help-file-name
     2524      (setq singular-scan-header-scan-for (append singular-scan-header-scan-for '(info-file))))
    24682525
    24692526  (add-hook 'singular-pre-output-filter-functions 'singular-scan-header-pre-output-filter))
     2527
     2528(defun singular-scan-header-exit ()
     2529  "Reinitialize scanning of header for Singular interactive mode.
     2530
     2531This function is called by `singular-exit-sentinel'."
     2532  ;; unset variables so that all subsequent calls of Singular will
     2533  ;; scan the header.
     2534  (singular-debug 'interactive (message "Deinitializing scan-header"))
     2535  (setq singular-emacs-home-directory nil)
     2536  (setq singular-help-file-name nil))
    24702537
    24712538;;
    24722539;; handling of emacs home directory
    24732540;;
     2541;; A note on `singular-emacs-home-directory': If this variable is set
     2542;; before singular.el is evaluated, the header of the first Singular
     2543;; started is NOT searched for the singular-emacs-home-directory.
     2544;; Anyhow, all subsequent calls of Singular will scan the header
     2545;; regardless of the initial state of this variable. (The exit-sentinel
     2546;; will set this variable back to nil.)
     2547;; See also `singular-scan-header-exit'.
    24742548(defvar singular-emacs-home-directory nil
    24752549  "Path to the emacs sub-directory of Singular as string.
     
    24932567
    24942568;;{{{ Filename, Command, and Help Completion
    2495 (defvar singular-commands-alist nil
    2496   "An alist containing all Singular commands to complete.
    2497 
    2498 This variable is buffer-local.")
    2499 
    2500 (defvar singular-help-topics-alist nil
    2501   "An alist containg all Singular help topics to complete.
    2502 
    2503 This variable is buffer-local.")
    2504 
    25052569(defun singular-completion-init ()
    25062570  "Initialize completion for Singular interactive mode.
     
    33043368
    33053369;;{{{ Starting singular
    3306 ;; TODO: should be defcustom
    3307 (defvar singular-start-file "~/.emacs_singularrc"
     3370(defcustom singular-start-file "~/.emacs_singularrc"
    33083371  "Name of start-up file to pass to Singular.
    33093372If the file named by this variable exists it is given as initial input
    33103373to any Singular process being started.  Note that this may lose due to
    3311 a timing error if Singular discards input when it starts up.")
    3312 
    3313 ;; TODO: should be defcustom
    3314 (defvar singular-executable-default "Singular"
     3374a timing error if Singular discards input when it starts up."
     3375  :type 'file
     3376  :initialize 'custom-initialize-default
     3377  :group 'singular-interactive-miscellaneous)
     3378
     3379(defcustom singular-executable-default "Singular"
    33153380  "Default name of Singular executable.
    3316 Used by `singular' when new Singular processes are started.")
     3381Used by `singular' when new Singular processes are started.
     3382If the name is given without path the executable is searched using the
     3383`PATH' environment variable."
     3384  :type 'file
     3385  :initialize 'custom-initialize-default
     3386  :group 'singular-interactive-miscellaneous)
    33173387
    33183388(defvar singular-executable-last singular-executable-default
    3319   "")
    3320 
    3321 ;; TODO: should be defcustom
    3322 (defvar singular-directory-default "."
    3323   "Default working directory of Singular buffer.")
     3389  "Singular executable name of the last Singular command used.
     3390
     3391This variable is buffer-local.")
     3392
     3393(defcustom singular-directory-default nil
     3394  "Default working directory of Singular buffer.
     3395Should be either nil (which means do not set the default directory) or an
     3396existing directory."
     3397  :type '(choice (const nil) (directory :value "~/"))
     3398  :initialize 'custom-initialize-default
     3399  :group 'singular-interactive-miscellaneous)
    33243400
    33253401(defvar singular-directory-last singular-directory-default
    3326   "")
     3402  "Working directory of last Singular command used.
     3403
     3404This variable is buffer-local.")
    33273405
    33283406;; no singular-directory-history here. Usual file history is used.
    33293407
    3330 ;; TODO: should be defcustom
    3331 (defvar singular-switches-default '()
    3332   "Default switches for Singular processes.
    3333 Should be a list of string, one string for each switch.
    3334 Used by `singular' when new Singular processes are started.")
     3408(defcustom singular-switches-default '()
     3409  "List of default switches for Singular processes.
     3410Should be a list of strings, one string for each switch.
     3411Used by `singular' when new Singular processes are started."
     3412  :type '(repeat string)
     3413  :initialize 'custom-initialize-default
     3414  :group 'singular-interactive-miscellaneous)
    33353415
    33363416(defvar singular-switches-last singular-switches-default
    3337   "")
     3417  "Switches of last Singular command used.
     3418
     3419This variable is buffer-local.")
    33383420
    33393421(defvar singular-switches-history nil
    3340   "")
     3422  "History list of Singular switches.")
    33413423
    33423424(defvar singular-switches-magic '("--emacs")
     
    33473429running an older version of Singular, remove this option from the list.")
    33483430
    3349 ;; TODO: should be defcustom
    3350 (defvar singular-name-default "singular"
     3431(defcustom singular-name-default "singular"
    33513432  "Default process name for Singular process.
    3352 Used by `singular' when new Singular processes are started.")
     3433Used by `singular' when new Singular processes are started.
     3434This string surrounded by \"*\" will also be the buffer name."
     3435  :type 'string
     3436  :initialize 'custom-initialize-default
     3437  :group 'singular-interactive-miscellaneous)
    33533438
    33543439(defvar singular-name-last singular-name-default
    3355   "")
     3440  "provess name of the last Singular command used.
     3441
     3442This variable is buffer-local.")
    33563443
    33573444(defvar singular-name-history nil
    3358   "")
     3445  "History list of Singular process names.")
    33593446
    33603447(defun singular-exec-init ()
     
    33743461(defun singular-exit-sentinel (process message)
    33753462 "Clean up after termination of Singular.
    3376 Writes back input ring after regular termination of Singular if
    3377 process buffer is still alive."
     3463Writes back input ring after regular termination of Singular if process
     3464buffer is still alive, deinstalls the library menu und calls several other
     3465exit procedures."
    33783466  (save-excursion
    33793467    (singular-debug 'interactive
     
    33823470    (singular-demo-exit)
    33833471    (singular-menu-deinstall-libraries)
     3472    (singular-scan-header-exit)
    33843473    (if (string-match "finished\\|exited" message)
    33853474        (let ((process-buffer (process-buffer process)))
     
    34283517            (singular-simple-sec-init (point))
    34293518           
     3519            ;; completion should be initialized before scan header!
     3520            (singular-completion-init)
    34303521            (singular-scan-header-init)
    3431             (singular-completion-init)
    34323522
    34333523            ;; feed process with start file and read input ring.  Take
     
    34833573
    34843574Appends `singular-switches-magic' to switches.
     3575Sets default-directory if directory is not-nil.
    34853576Sets singular-*-last values."
    34863577  (singular-debug 'interactive
     
    34973588          (setq buffer (get-buffer-create buffer-name))
    34983589          (set-buffer buffer)
     3590          (and directory
     3591               (setq default-directory directory))
    34993592         
    35003593          (singular-debug 'interactive (message "Calling `singular-interactive-mode'"))
     
    35783671         ;; not-expanded name.
    35793672         (directory (file-name-directory (read-file-name "Default directory: "
    3580                                                          nil nil t)))
     3673                                                         nil
     3674                                                         (or singular-directory-default
     3675                                                             default-directory)
     3676                                                         t)))
    35813677         (switches "")
    35823678         (name (singular-generate-new-buffer-name
Note: See TracChangeset for help on using the changeset viewer.