1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236
|
;;; emacspeak-arc.el --- Speech enable archive-mode -- a Emacs interface to zip and friends
;;; $Id: emacspeak-arc.el 5798 2008-08-22 17:35:01Z tv.raman.tv $
;;; $Author: tv.raman.tv $
;;; Description: Auditory interface to archive mode
;;; Keywords: Emacspeak, Speak, Spoken Output, archive
;;{{{ LCD Archive entry:
;;; LCD Archive Entry:
;;; emacspeak| T. V. Raman |raman@cs.cornell.edu
;;; A speech interface to Emacs |
;;; $Date: 2008-06-21 10:50:41 -0700 (Sat, 21 Jun 2008) $ |
;;; $Revision: 4532 $ |
;;; Location undetermined
;;;
;;}}}
;;{{{ Copyright:
;;; Copyright (c) 1995 -- 2007, T. V. Raman
;;; All Rights Reserved.
;;;
;;; This file is not part of GNU Emacs, but the same permissions apply.
;;;
;;; GNU Emacs 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.
;;;
;;; GNU Emacs 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 GNU Emacs; see the file COPYING. If not, write to
;;; the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
;;}}}
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;{{{ Required modules
(require 'emacspeak-preamble)
(require 'arc-mode)
;;}}}
;;{{{ Introduction
;;;Auditory interface to archive mode
;;}}}
;;{{{ Helpers
(defun emacspeak-archive-speak-line ()
"Speak line in archive mode intelligently"
(end-of-line)
(cond
((null (char-after (1+ (point))))
(emacspeak-speak-line))
(t (skip-syntax-backward "^ ")
(emacspeak-speak-line 1))))
;;}}}
;;{{{ fix interactive commands that need fixing
;;}}}
;;{{{ Advice
(defadvice archive-mark (after emacspeak pre act comp)
"Provide auditory feedback"
(when (interactive-p)
(emacspeak-auditory-icon 'mark-object)
(emacspeak-archive-speak-line)))
(defadvice archive-next-line (after emacspeak pre act comp)
"Provide spoken feedback"
(when (interactive-p )
(emacspeak-archive-speak-line)))
(defadvice archive-previous-line (after emacspeak pre act comp)
"Provide spoken feedback"
(when (interactive-p )
(emacspeak-archive-speak-line)))
(defadvice archive-flag-deleted (after emacspeak pre act comp)
"Provide auditory feedback"
(when (interactive-p)
(emacspeak-auditory-icon 'delete-object)
(emacspeak-archive-speak-line)))
(defadvice archive-unflag (after emacspeak pre act comp)
"Provide auditory feedback"
(when (interactive-p)
(emacspeak-auditory-icon 'yank-object)
(emacspeak-archive-speak-line)))
(defadvice archive-unflag-backwards (after emacspeak pre act comp)
"Provide auditory feedback"
(when (interactive-p)
(emacspeak-auditory-icon 'yank-object)
(emacspeak-archive-speak-line)))
(defadvice archive-extract (after emacspeak pre act comp)
"Provide auditory feedback"
(when (interactive-p)
(emacspeak-auditory-icon 'open-object)
(emacspeak-speak-mode-line)))
(defadvice archive-extract-other-window (after emacspeak pre act comp)
"Provide auditory feedback"
(when (interactive-p)
(emacspeak-auditory-icon 'open-object)
(emacspeak-speak-mode-line)))
(defadvice archive-view (after emacspeak pre act comp)
"Provide auditory feedback"
(when (interactive-p)
(emacspeak-auditory-icon 'open-object)
(emacspeak-speak-mode-line)))
;;}}}
;;{{{ interactive commands
(defvar emacspeak-arc-header-list-format nil
"Field names in the header line")
(defsubst emacspeak-arc-get-header-line-format ()
"Return header line format vector, after
first initializing it if necessary."
(declare (special emacspeak-arc-header-list-format))
(unless emacspeak-arc-header-list-format
(let ((line nil)
(fields nil))
(save-excursion
(goto-char (point-min))
(setq line (thing-at-point 'line)))
(setq fields (split-string line))
(loop for f in fields
and i from 0
do
(setq emacspeak-arc-header-list-format
(cons
(list f i )
emacspeak-arc-header-list-format)))))
emacspeak-arc-header-list-format)
(defsubst emacspeak-arc-get-field-index (field)
(let ((marked-p (save-excursion
(beginning-of-line)
(= (following-char) ?\ )))
(position (cadr (assoc field
(emacspeak-arc-get-header-line-format)))))
(if marked-p
(1- position)
position )))
(defun emacspeak-arc-speak-file-name ()
"Speak the name of the file on current line"
(interactive)
(unless (eq major-mode 'archive-mode)
(error "This command should be called only in archive mode"))
(let ((entry (archive-get-descr 'no-error)))
(cond
((null entry)
(message "No file on this line"))
(t
(message "File: %s"
(nth (emacspeak-arc-get-field-index "File")
(split-string (thing-at-point 'line))))))))
(defun emacspeak-arc-speak-file-size ()
"Speak the size of the file on current line"
(interactive)
(unless (eq major-mode 'archive-mode)
(error "This command should be called only in archive mode"))
(let ((entry (archive-get-descr 'no-error)))
(cond
((null entry)
(message "No file on this line"))
(t
(message "Size: %s"
(nth (emacspeak-arc-get-field-index "Length")
(split-string (thing-at-point 'line))))))))
(defun emacspeak-arc-speak-file-modification-time ()
"Speak modification time of the file on current line"
(interactive)
(unless (eq major-mode 'archive-mode)
(error "This command should be called only in archive mode"))
(let ((entry (archive-get-descr 'no-error)))
(cond
((null entry)
(message "No file on this line"))
(t
(let* ((fields (split-string (thing-at-point 'line)))
(date (nth (emacspeak-arc-get-field-index "Date")
fields))
(time (nth (emacspeak-arc-get-field-index "Time")
fields)))
(message "Modified on %s at %s"
date time))))))
(defun emacspeak-arc-speak-file-permissions()
"Speak permissions of file current entry "
(interactive)
(unless (eq major-mode 'archive-mode)
(error "This command should be called only in archive mode"))
(let ((entry (archive-get-descr 'no-error))
(mode nil))
(cond
((null entry)
(message "No file on this line"))
(t
(setq mode
(archive-int-to-mode
(aref entry 3)))
(message "Permissions %s "
mode)))))
(defun emacspeak-arc-setup-keys ()
"Setup emacspeak keys for arc mode"
(declare (special archive-mode-map))
(define-key archive-mode-map "." 'emacspeak-arc-speak-file-name)
(define-key archive-mode-map "c" 'emacspeak-arc-speak-file-modification-time)
(define-key archive-mode-map "z" 'emacspeak-arc-speak-file-size)
(define-key archive-mode-map "/"
'emacspeak-arc-speak-file-permissions)
)
(eval-when (load)
(emacspeak-arc-setup-keys))
;;}}}
(provide 'emacspeak-arc)
;;{{{ end of file
;;; local variables:
;;; folded-file: t
;;; byte-compile-dynamic: t
;;; end:
;;}}}
|