emacs.d

My Emacs configuration
git clone https://git.jamzattack.xyz/emacs.d
Log | Files | Refs | LICENSE

ed.el (1524B)


      1 ;;; ed.el --- a decent editor within GNU Emacs
      2 ;; Copyright (C) 2018 Jamie Beardslee
      3 
      4 ;; Author: Jamie Beardslee <jdb@jamzattack.xyz>
      5 ;; Keywords: convenience
      6 
      7 ;; This program is free software; you can redistribute it and/or modify
      8 ;; it under the terms of the GNU General Public License as published by
      9 ;; the Free Software Foundation, either version 3 of the License, or
     10 ;; (at your option) any later version.
     11 
     12 ;; This program is distributed in the hope that it will be useful,
     13 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
     14 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     15 ;; GNU General Public License for more details.
     16 
     17 ;; You should have received a copy of the GNU General Public License
     18 ;; along with this program.  If not, see <http://www.gnu.org/licenses/>.
     19 
     20 ;;; Commentary:
     21 
     22 ;; This package provides `ed-find-file', an interface for opening
     23 ;; files in ed(1), the standard editor.
     24 ;;
     25 ;; Recommendation: (global-set-key [remap find-file] 'ed-find-file)
     26 
     27 ;;; Code:
     28 
     29 
     30 (defvar ed-use-prompt t
     31   "If t, change the prompt to \"> \". This will only work with
     32 posix-compliant implementations of ed. Set this to nil if you
     33 use busybox.")
     34 
     35 
     36 (defun ed-find-file (file)
     37   "Open a file with ed, the standard editor. See ed(1) for usage."
     38   (interactive "F")
     39   (let ((basename (file-name-base file)))
     40     (switch-to-buffer
     41      (make-comint (concat "ed " basename)
     42 		  "ed"
     43 		  nil
     44 		  file
     45 		  (if ed-use-prompt
     46 		      "-p> "
     47 		    "")))
     48     (cd (file-name-directory file))))
     49 
     50 (provide 'ed)