home *** CD-ROM | disk | FTP | other *** search
/ InfoMagic Source Code 1993 July / THE_SOURCE_CODE_CD_ROM.iso / gnu / lucid / lemacs-19.6 / lisp / vms / vms-patch.el next >
Encoding:
Text File  |  1992-06-29  |  3.7 KB  |  100 lines

  1. ;; Override parts of files.el for VMS.
  2. ;; Copyright (C) 1986 Free Software Foundation, Inc.
  3.  
  4. ;; This file is part of GNU Emacs.
  5.  
  6. ;; GNU Emacs is free software; you can redistribute it and/or modify
  7. ;; it under the terms of the GNU General Public License as published by
  8. ;; the Free Software Foundation; either version 1, or (at your option)
  9. ;; any later version.
  10.  
  11. ;; GNU Emacs is distributed in the hope that it will be useful,
  12. ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  14. ;; GNU General Public License for more details.
  15.  
  16. ;; You should have received a copy of the GNU General Public License
  17. ;; along with GNU Emacs; see the file COPYING.  If not, write to
  18. ;; the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
  19.  
  20.  
  21. ;;; Functions that need redefinition
  22.  
  23. ;;; VMS file names are upper case, but buffer names are more
  24. ;;; convenient in lower case.
  25.  
  26. (defun create-file-buffer (filename)
  27.   "Create a suitably named buffer for visiting FILENAME, and return it.
  28. FILENAME (sans directory) is used unchanged if that name is free;
  29. otherwise a string <2> or <3> or ... is appended to get an unused name."
  30.   (generate-new-buffer (downcase (file-name-nondirectory filename))))
  31.  
  32. ;;; Given a string FN, return a similar name which is a legal VMS filename.
  33. ;;; This is used to avoid invalid auto save file names.
  34. (defun make-legal-file-name (fn)
  35.   (setq fn (copy-sequence fn))
  36.   (let ((dot nil) (indx 0) (len (length fn)) chr)
  37.     (while (< indx len)
  38.       (setq chr (aref fn indx))
  39.       (cond
  40.        ((eq chr ?.) (if dot (aset fn indx ?_) (setq dot t)))
  41.        ((not (or (and (>= chr ?a) (<= chr ?z)) (and (>= chr ?A) (<= chr ?Z))
  42.          (and (>= chr ?0) (<= chr ?9))
  43.          (eq chr ?$) (eq chr ?_) (and (eq chr ?-) (> indx 0))))
  44.     (aset fn indx ?_)))
  45.       (setq indx (1+ indx))))
  46.   fn)
  47.  
  48. ;;; Auto save filesnames start with _$ and end with $.
  49.  
  50. (defun make-auto-save-file-name ()
  51.   "Return file name to use for auto-saves of current buffer.
  52. Does not consider auto-save-visited-file-name; that is checked
  53. before calling this function.
  54. This is a separate function so your .emacs file or site-init.el can redefine it.
  55. See also auto-save-file-name-p."
  56.   (if buffer-file-name
  57.       (concat (file-name-directory buffer-file-name)
  58.           "_$"
  59.           (file-name-nondirectory buffer-file-name)
  60.           "$")
  61.     (expand-file-name (concat "_$_" (make-legal-file-name (buffer-name)) "$"))))
  62.  
  63. (defun auto-save-file-name-p (filename)
  64.   "Return t if FILENAME can be yielded by make-auto-save-file-name.
  65. FILENAME should lack slashes.
  66. This is a separate function so your .emacs file or site-init.el can redefine it."
  67.   (string-match "^_\\$.*\\$" filename))
  68.  
  69. (defun vms-suspend-resume-hook ()
  70.   "When resuming suspended Emacs, check for file to be found.
  71. If the logical name `EMACS_FILE_NAME' is defined, `find-file' that file."
  72.   (let ((file (vms-system-info "LOGICAL" "EMACS_FILE_NAME")))
  73.     (if file (find-file file))))
  74.  
  75. (setq suspend-resume-hook 'vms-suspend-resume-hook)
  76.  
  77. (defun vms-suspend-hook ()
  78.   "Don't allow suspending if logical name `DONT_SUSPEND_EMACS' is defined."
  79.   (if (vms-system-info "LOGICAL" "DONT_SUSPEND_EMACS")
  80.       (error "Can't suspend this emacs"))
  81.   nil)
  82.  
  83. (setq suspend-hook 'vms-suspend-hook)
  84.  
  85. (defun vms-read-directory (dirname switches buffer)
  86.   (save-excursion
  87.     (set-buffer buffer)
  88.     (subprocess-command-to-buffer
  89.      (concat "DIRECTORY " switches " " dirname)
  90.      buffer)
  91.     (goto-char (point-min))
  92.     ;; Remove all the trailing blanks.
  93.     (while (search-forward " \n")
  94.       (forward-char -1)
  95.       (delete-horizontal-space))
  96.     (goto-char (point-min))))
  97.  
  98. (setq dired-listing-switches
  99.       "/SIZE/DATE/OWNER/WIDTH=(FILENAME=32,SIZE=5)")
  100.