[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
files+.el - extensions to GNU `files.el'
From: |
Drew Adams |
Subject: |
files+.el - extensions to GNU `files.el' |
Date: |
Tue, 16 Jan 2001 21:35:20 -0500 |
;;; files+.el --- Redefinitions of some functions from `files.el'.
;;
;; Emacs Lisp Archive Entry
;; Filename: files+.el
;; Description: Redefinitions of some functions from `files.el'.
;; Author: Drew Adams
;; Maintainer: Drew Adams
;; Copyright (C) 1996-2001, Drew Adams, all rights reserved.
;; Created: Fri Aug 11 14:24:13 1995
;; Version: $Id: files+.el,v 1.4 2001/01/08 22:47:09 dadams Exp $
;; Last-Updated: Mon Jan 8 14:47:02 2001
;; By: dadams
;; Update #: 134
;; Keywords: internal, extensions, local
;; Compatibility: GNU Emacs 20.x
;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;
;;; Commentary:
;;
;; Redefinitions of some functions from `files.el'. The new
;; definitions use `read-buffer' (not "B...") in interactive calls.
;;
;;
;; ***** NOTE: The following functions defined in `files.el' have been
;; REDEFINED HERE:
;;
;; `switch-to-buffer-other-window' -
;; 1. Uses `read-buffer' (interactive). 2. defun -> defsubst.
;; `switch-to-buffer-other-frame' -
;; 1. Uses `read-buffer' (interactive). 2. defun -> defsubst.
;;
;;
;; This file should be loaded after loading the standard GNU file
;; `files.el'. So, in your `~/.emacs' file, do this:
;; (eval-after-load "files" '(require 'files+))
;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;
;;; Change log:
;;
;; RCS $Log: files+.el,v $
;; RCS Revision 1.4 2001/01/08 22:47:09 dadams
;; RCS Adapted file header for Emacs Lisp Archive.
;; RCS
;; RCS Revision 1.3 2001/01/03 17:35:11 dadams
;; RCS *** empty log message ***
;; RCS
;; RCS Revision 1.2 2001/01/03 00:37:08 dadams
;; RCS *** empty log message ***
;; RCS
;; RCS Revision 1.1 2000/09/14 15:48:13 dadams
;; RCS Initial revision
;; RCS
; Revision 1.2 1999/03/17 13:31:15 dadams
; switch-to-buffer-other-frame: Removed call to raise-frame.
;
; Revision 1.1 1997/03/20 09:46:33 dadams
; Initial revision
;
; Revision 1.15 1996/07/01 12:53:14 dadams
; (trivial)
;
; Revision 1.14 1996/06/06 13:36:13 dadams
; Update of file dependency comments (e.g. "Autoloaded from...").
;
; Revision 1.13 1996/04/26 09:09:09 dadams
; Put escaped newlines on long-line strings.
;
; Revision 1.12 1996/04/05 14:23:25 dadams
; Improved Commentary: List redefinitions.
;
; Revision 1.11 1996/03/20 15:30:23 dadams
; switch-to-buffer-other-window, switch-to-buffer-other-frame:
; defun -> defsubst.
;
; Revision 1.10 1996/03/11 08:23:38 dadams
; (trivial: untabified)
;
; Revision 1.9 1996/03/07 17:07:44 dadams
; Copyright.
;
; Revision 1.8 1996/02/12 09:36:31 dadams
; Updated header keywords (for finder).
;
; Revision 1.7 1996/01/12 17:04:27 dadams
; 1. Removed switch-to-buffer to drew-window-cmds.el (it wasn't in files.el).
; 2. switch-to-buffer-other-frame: No longer raise-frame, (see pop-to-buffer).
;
; Revision 1.6 1996/01/09 09:10:06 dadams
; (trivial)
;
; Revision 1.5 1996/01/02 16:38:07 dadams
; `switch-to-buffer' moved here from `drew-misc-19.el'.
;
; Revision 1.4 1995/12/28 15:29:01 dadams
; Added ;;;###autoloads.
;
; Revision 1.3 1995/10/24 07:43:03 dadams
; Added corrected (?) version of set-auto-mode, but commented it out
; since original (bugged?) version is depended on in other places.
;
; Revision 1.2 1995/09/04 14:19:31 dadams
; *** empty log message ***
;
; Revision 1.1 1995/09/04 14:18:19 dadams
; Initial revision
;
; Previously was in `files.el':
; 1995/08/11 12:40:30 dadams
; 1) Provide this.
; 2) interactive "B..." -> use read-buffer instead.
;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;
;; This program is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation; either version 2, or (at your option)
;; any later version.
;; This program is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;; GNU General Public License for more details.
;; You should have received a copy of the GNU General Public License
;; along with this program; see the file COPYING. If not, write to the
;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
;; Boston, MA 02111-1307, USA.
;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;
;;; Code:
;; Cannot do (require 'files), because `files.el' does no `provide'.
;; Don't want to do a (load-library "files") either, because it wouldn't
;; allow doing (eval-after-load "files" '(progn (require 'files+)))
(provide 'files+)
;;;;;;;;;;;;;;;;;;;;;
;; REPLACES ORIGINAL in `files.el':
;; 1. Uses `read-buffer' (not "B...") in the interactive spec.
;; 2. defun -> defsubst.
(defsubst switch-to-buffer-other-window (buffer)
"Select buffer BUFFER in another window."
(interactive (list (read-buffer "Switch to buffer in other window: ")))
(let ((pop-up-windows t)) (pop-to-buffer buffer t)))
;; REPLACES ORIGINAL in `files.el':
;; 1. Uses `read-buffer' (not "B...") in the interactive spec.
;; 2. defun -> defsubst.
(defsubst switch-to-buffer-other-frame (buffer)
"Switch to buffer BUFFER in another frame."
(interactive (list (read-buffer "Switch to buffer in other frame: ")))
(let ((pop-up-frames t)) (pop-to-buffer buffer t))
;; Not needed if use my `pop-to-buffer':
(raise-frame (window-frame (selected-window))))
;;; `XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'
;; 1995 -
;; D. Adams: It seems to me that the original `set-auto-mode' is bugged.
;; It doesn't seem to correspond to the doc string of
;; `auto-mode-alist': One should be able to use (REGEXP FN), but it
;; appears that (REGEXP FN FN) is needed instead. I would correct it
;; as follows, but there appear to be other programs (e.g.
;; `jka-compr.el') that now require the form (REGEXP FN FN), or
;; (REGEXP nil FN).
;; Anyway, here is my correction (commented out for now):
;; The original has (nth 2 alist), below, instead of (nth 1 alist).
;;(defun set-auto-mode ()
;; "Select major mode appropriate for current buffer.
;;This checks for a -*- mode tag in the buffer's text, compares the filename
;;against the entries in `auto-mode-alist', or checks the interpreter that
;;runs this file against `interpreter-mode-alist'.
;;It does not check for the `mode:' local variable in the
;;Local Variables section of the file; for that, use `hack-local-variables'.
;;If `enable-local-variables' is nil, this function does not check for a
;;-*- mode tag."
;; ;; Look for -*-MODENAME-*- or -*- ... mode: MODENAME; ... -*-
;; (let (beg end done)
;; (save-excursion
;; (goto-char (point-min))
;; (skip-chars-forward " \t\n")
;; (and enable-local-variables
;; ;; Don't look for -*- if this file name matches any
;; ;; of the regexps in inhibit-first-line-modes-regexps.
;; (let ((temp inhibit-first-line-modes-regexps))
;; (while (and temp
;; (not (string-match (car temp)
;; buffer-file-name)))
;; (setq temp (cdr temp)))
;; (not temp))
;; (search-forward "-*-" (save-excursion
;; ;; If the file begins with "#!"
;; ;; (exec interpreter magic), look
;; ;; for mode frobs in the first two
;; ;; lines. You cannot necessarily
;; ;; put them in the first line of
;; ;; such a file without screwing up
;; ;; the interpreter invocation.
;; (end-of-line (and (looking-at "^#!") 2))
;; (point)) t)
;; (progn
;; (skip-chars-forward " \t")
;; (setq beg (point))
;; (search-forward "-*-"
;; (save-excursion (end-of-line) (point))
;; t))
;; (progn
;; (forward-char -3)
;; (skip-chars-backward " \t")
;; (setq end (point))
;; (goto-char beg)
;; (if (save-excursion (search-forward ":" end t))
;; ;; Find all specifications for the `mode:' variable
;; ;; and execute them left to right.
;; (while (let ((case-fold-search t))
;; (search-forward "mode:" end t))
;; (skip-chars-forward " \t")
;; (setq beg (point))
;; (if (search-forward ";" end t)
;; (forward-char -1)
;; (goto-char end))
;; (skip-chars-backward " \t")
;; (funcall (intern (concat (downcase
;; (buffer-substring beg (point)))
;; "-mode"))))
;; ;; Simple -*-MODE-*- case.
;; (funcall (intern (concat (downcase (buffer-substring beg end))
;; "-mode"))))
;; (setq done t)))
;; ;; If we didn't find a mode from a -*- line, try using the file name.
;; (if (and (not done) buffer-file-name)
;; (let ((name buffer-file-name)
;; (keep-going t))
;; ;; Remove backup-suffixes from file name.
;; (setq name (file-name-sans-versions name))
;; (while keep-going
;; (setq keep-going nil)
;; (let ((alist auto-mode-alist)
;; (mode nil))
;; ;; Find first matching alist entry.
;; (let ((case-fold-search (eq system-type 'vax-vms)))
;; (while (and (not mode) alist)
;; (if (string-match (car (car alist)) name)
;; (if (and (consp (cdr (car alist)))
;; (nth 1 (car alist)))
;; (progn
;; (setq mode (car (cdr (car alist)))
;; name (substring name 0 (match-beginning 0))
;; keep-going t))
;; (setq mode (cdr (car alist))
;; keep-going nil)))
;; (setq alist (cdr alist))))
;; (if mode
;; (funcall mode)
;; ;; If we can't deduce a mode from the file name,
;; ;; look for an interpreter specified in the first line.
;; (let ((interpreter
;; (save-excursion
;; (goto-char (point-min))
;; (if (looking-at "#! *\\([^ \t\n]+\\)")
;; (buffer-substring (match-beginning 1)
;; (match-end 1))
;; "")))
;; elt)
;; ;; Map interpreter name to a mode.
;; (setq elt (assoc (file-name-nondirectory interpreter)
;; interpreter-mode-alist))
;; (if elt
;; (funcall (cdr elt))))))))))))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;; `files+.el' ends here
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- files+.el - extensions to GNU `files.el',
Drew Adams <=