• Home
  • History
  • Annotate
  • Raw
  • Download
  • only in /macosx-10.10/emacs-93/emacs/lisp/gnus/

Lines Matching +defs:buffer +defs:file +defs:name

1 ;;; nneething.el --- arbitrary file access for Gnus
10 ;; This file is part of GNU Emacs.
23 ;; along with GNU Emacs; see the file COPYING. If not, write to the
40 (defvoo nneething-map-file-directory
44 (defvoo nneething-map-file ".nneething"
69 (defvoo nneething-work-buffer " *nneething work*")
88 (set-buffer nntp-server-buffer)
89 (erase-buffer)
94 article file)
100 (setq file (nneething-file-name article))
102 (when (and (file-exists-p file)
103 (or (file-directory-p file)
104 (not (zerop (nnheader-file-size file)))))
106 (nneething-insert-head file)
122 (deffoo nneething-request-article (id &optional group server buffer)
124 (let ((file (unless (stringp id)
125 (nneething-file-name id)))
126 (nntp-server-buffer (or buffer nntp-server-buffer)))
127 (and (stringp file) ; We did not request by Message-ID.
128 (file-exists-p file) ; The file exists.
129 (not (file-directory-p file)) ; It's not a dir.
131 (let ((nnmail-file-coding-system 'binary))
132 (nnmail-find-file file)) ; Insert the file in the nntp buf.
135 (unless (file-directory-p file)
136 (or (cdr (assoc (concat "." (file-name-extension file))
146 (nneething-make-head file (current-buffer)
178 (nnheader-init-server-buffer)
200 (defun nneething-map-file ()
202 (gnus-make-directory nneething-map-file-directory)
204 (concat (file-name-as-directory nneething-map-file-directory)
205 nneething-group nneething-map-file))
209 (when (file-exists-p nneething-address)
210 (let ((map-file (nneething-map-file))
213 (when (file-exists-p map-file)
215 (load map-file nil t t)))
224 (nth 5 (file-attributes
225 (nneething-file-name (car n))))))
253 (equal (nth 5 (file-attributes
254 (nneething-file-name (cadr (car map)))))
267 ;; This file is not in the map, so we enter it.
271 (nth 5 (file-attributes
272 (nneething-file-name (car files)))))
277 (with-temp-file map-file
284 (defun nneething-insert-head (file)
286 (when (nneething-get-head file)
287 (insert-buffer-substring nneething-work-buffer)
290 (defun nneething-encode-file-name (file &optional coding-system)
291 "Encode the name of the FILE in CODING-SYSTEM."
293 (setq file (mm-encode-coding-string
294 file (or coding-system nnmail-pathname-coding-system)))
295 (while (string-match "[^-0-9a-zA-Z_:/.]" file pos)
296 (setq buf (cons (format "%%%02x" (aref file (match-beginning 0)))
297 (cons (substring file pos (match-beginning 0)) buf))
300 (nreverse (cons (substring file pos) buf)))))
302 (defun nneething-decode-file-name (file &optional coding-system)
303 "Decode the name of the FILE is encoded in CODING-SYSTEM."
305 (while (string-match "%\\([0-9a-fA-F][0-9a-fA-F]\\)" file pos)
306 (setq buf (cons (string (string-to-number (match-string 1 file) 16))
307 (cons (substring file pos (match-beginning 0)) buf))
311 (nreverse (cons (substring file pos) buf)))
314 (defun nneething-get-file-name (id)
315 "Extract the file name from the message ID string."
317 (nneething-decode-file-name (match-string 1 id))))
319 (defun nneething-make-head (file &optional buffer extra-msg
321 "Create a head by looking at the file attributes of FILE."
322 (let ((atts (file-attributes file)))
324 "Subject: " (file-name-nondirectory file) (or extra-msg "") "\n"
325 "Message-ID: <nneething-" (nneething-encode-file-name file)
326 "@" (system-name) ">\n"
329 (or (when buffer
331 (set-buffer buffer)
334 (nneething-from-line (nth 2 atts) file))
338 (if buffer
340 (set-buffer buffer)
351 (symbol-name mime-charset)))
359 (defun nneething-from-line (uid &optional file)
362 (user-login-name uid)
364 (cond ((= uid (user-uid)) (user-login-name))
367 (name (condition-case nil
368 (user-full-name uid)
370 (cond ((= uid (user-uid)) (user-full-name))
372 (host (if (string-match "\\`/[^/@]*@\\([^:/]+\\):" file)
374 (substring file
378 "/\\(users\\|home\\)/\\([^/]+\\)/" file)
379 (setq login (substring file
382 name nil)))
383 (system-name))))
385 (if name (concat " (" name ")") "") "\n")))
387 (defun nneething-get-head (file)
390 (set-buffer (get-buffer-create nneething-work-buffer))
392 (buffer-disable-undo)
393 (erase-buffer)
395 ((not (file-exists-p file))
396 ;; The file do not exist.
398 ((or (file-directory-p file)
399 (file-symlink-p file))
401 (nneething-make-head file) t)
403 ;; We examine the file.
406 (nnheader-insert-head file)
416 (nneething-make-head file (current-buffer))
418 (file-error
419 (nneething-make-head file (current-buffer) " (unreadable)")))
422 (defun nneething-file-name (article)
423 "Return the file name of ARTICLE."
424 (let ((dir (file-name-as-directory nneething-address))
428 (expand-file-name fname dir)
429 (mm-make-temp-file (expand-file-name "nneething" dir)))
430 (expand-file-name article dir))))