Gnus development mailing list
 help / color / mirror / Atom feed
* request feedback on new function gnus-dired-attach
@ 2001-12-15  0:19 Benjamin Rutt
  2001-12-15  5:25 ` Benjamin Rutt
  2001-12-15  6:12 ` ShengHuo ZHU
  0 siblings, 2 replies; 14+ messages in thread
From: Benjamin Rutt @ 2001-12-15  0:19 UTC (permalink / raw)


After getting inspired today to clean out my TODO list, I defined the
following function, to make it easier to attach (multiple) files in
gnus via dired buffers.  (This is in response to a thread with the
subject 'how to attach multiple attachments simultaneously' on
gnu.emacs.gnus during late November of this year...it has since
expired from my news server, otherwise I'd probably followup to it).
I'd love to get the following feedback:

1) reports of failures under setups other than GNU Emacs 21+Oort,
   which is the system I've tested it on

2) whether and how to integrate this code into gnus.  You'll note that
   the last line:

(define-key dired-mode-map [(control c) (control a)] 'gnus-dired-attach)

   is somewhat ugly, since we are defining a dired keymap in another
   area of code.  Paul Jarc, on the above g.e.g thread, suggested that
   we define a gnus-dired minor mode which can contain the keymap.
   But I'm not sure if that's better, since ultimately we're still
   stealing a possible future dired keybinding (C-c C-a currently
   isn't defined in dired-mode).  Maybe that last line should simply
   go in users ~/.gnus so the users control the keybinding override?

3) whether you think this should exist as a separate file that isn't
   included in gnus.

4) any other feedback

Here begins the code.  It should be enough to place this code in your
~~/.gnus, evaluate it, and then start attaching files from dired
buffers via C-c C-a (with or without starting message compositions
first).  Thanks.

----------------------------------------------------------------------

(defun gnus-dired-attach ()
  "Attach dired's marked files to a gnus message composition."
  (interactive)
  (let* ((files-to-attach
	  ;; don't attach directories
	  (delq nil
		(mapcar
		 (lambda (f) (if (file-directory-p f) nil f))
		 (nreverse (dired-map-over-marks (dired-get-filename) nil)))))
	 (destination nil)
	 (files-str (mapconcat
		     (lambda (f) (file-name-nondirectory f)) files-to-attach
		     ", "))
	 (bufs (message-buffers)))
    
    ;; set up destination message buffer
    (if (and bufs
	     (y-or-n-p "Attach files to existing message buffer? "))
	(setq destination
	      (if (= (length bufs) 1)
		  (get-buffer (car bufs))
		(completing-read "Attach to which message buffer: "
				 (mapcar
				  (lambda (b)
				    (cons b (get-buffer b)))
				  bufs)
				 nil t)))
      ;; setup a new gnus message buffer
      (gnus-setup-message 'message (message-mail))
      (setq destination (current-buffer)))

    ;; set buffer to destination buffer, and attach files
    (set-buffer destination)
    (goto-char (point-max)) ;attach at end of buffer
    (while files-to-attach
      (mml-attach-file (car files-to-attach)
		       (or (mm-default-file-encoding (car files-to-attach))
			   "application/octet-stream") nil)
      (setq files-to-attach (cdr files-to-attach)))
    (message "attached files %s" files-str)))
(define-key dired-mode-map [(control c) (control a)] 'gnus-dired-attach)
-- 
Benjamin




^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: request feedback on new function gnus-dired-attach
  2001-12-15  0:19 request feedback on new function gnus-dired-attach Benjamin Rutt
@ 2001-12-15  5:25 ` Benjamin Rutt
  2001-12-15  6:12 ` ShengHuo ZHU
  1 sibling, 0 replies; 14+ messages in thread
From: Benjamin Rutt @ 2001-12-15  5:25 UTC (permalink / raw)


Benjamin Rutt <rutt+news@cis.ohio-state.edu> writes:

> (defun gnus-dired-attach ()

One minor fix.  I realized that it shouldn't start attaching if no
dired files have been marked.  So, here's the code again with that bug
squashed:

(defun gnus-dired-attach ()
  "Attach dired's marked files to a gnus message composition."
  (interactive)
  (let ((files-to-attach
	 ;; don't attach directories
	 (delq nil
	       (mapcar
		(lambda (f) (if (file-directory-p f) nil f))
		(nreverse (dired-map-over-marks (dired-get-filename) nil)))))
	(destination nil)
	(files-str nil)
	(bufs nil))
    ;; warn if user tries to attach without any files marked 
    (if (null files-to-attach)
	(message "No files marked to attach")
      (setq files-str
	    (mapconcat
	     (lambda (f) (file-name-nondirectory f))
	     files-to-attach ", "))
      (setq bufs (message-buffers))
    
      ;; set up destination message buffer
      (if (and bufs
	       (y-or-n-p "Attach files to existing message buffer? "))
	  (setq destination
		(if (= (length bufs) 1)
		    (get-buffer (car bufs))
		  (completing-read "Attach to which message buffer: "
				   (mapcar
				    (lambda (b)
				      (cons b (get-buffer b)))
				    bufs)
				   nil t)))
	;; setup a new gnus message buffer
	(gnus-setup-message 'message (message-mail))
	(setq destination (current-buffer)))

      ;; set buffer to destination buffer, and attach files
      (set-buffer destination)
      (goto-char (point-max))		;attach at end of buffer
      (while files-to-attach
	(mml-attach-file (car files-to-attach)
			 (or (mm-default-file-encoding (car files-to-attach))
			     "application/octet-stream") nil)
	(setq files-to-attach (cdr files-to-attach)))
      (message "attached files %s" files-str))))
(define-key dired-mode-map [(control c) (control a)] 'gnus-dired-attach)


-- 
Benjamin




^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: request feedback on new function gnus-dired-attach
  2001-12-15  0:19 request feedback on new function gnus-dired-attach Benjamin Rutt
  2001-12-15  5:25 ` Benjamin Rutt
@ 2001-12-15  6:12 ` ShengHuo ZHU
  2001-12-15  6:39   ` Benjamin Rutt
                     ` (2 more replies)
  1 sibling, 3 replies; 14+ messages in thread
From: ShengHuo ZHU @ 2001-12-15  6:12 UTC (permalink / raw)


Benjamin Rutt <rutt+news@cis.ohio-state.edu> writes:

[...]

> 2) whether and how to integrate this code into gnus.  You'll note that
>    the last line:
>
> (define-key dired-mode-map [(control c) (control a)] 'gnus-dired-attach)
>
>    is somewhat ugly, since we are defining a dired keymap in another
>    area of code.  Paul Jarc, on the above g.e.g thread, suggested that
>    we define a gnus-dired minor mode which can contain the keymap.
>    But I'm not sure if that's better, since ultimately we're still
>    stealing a possible future dired keybinding (C-c C-a currently
>    isn't defined in dired-mode).  Maybe that last line should simply
>    go in users ~/.gnus so the users control the keybinding override?

Why not do both?  We can steal a special (or customizable) prefix for
gnus-dired minor mode.  Users still can set C-c C-a in dired-mode-map
to the function.  This would be less intrusive.

> 3) whether you think this should exist as a separate file that isn't
>    included in gnus.

It is better to add a separate file, say gnus-dired.el, for gnus-dired
minor mode. If you'd like to add your code to Gnus package, you'd
better send an assignment form to FSF (unless you've signed the form).
I can send you the request form.

In addition, I have a piece of code to open file (in dired-mode)
according to mailcap.  I'd like to include it too.

> Here begins the code.  It should be enough to place this code in your
> ~~/.gnus, evaluate it, and then start attaching files from dired
> buffers via C-c C-a (with or without starting message compositions
> first).  Thanks.
>
> ----------------------------------------------------------------------
>
> (defun gnus-dired-attach ()
>   "Attach dired's marked files to a gnus message composition."
>   (interactive)
>   (let* ((files-to-attach
> 	  ;; don't attach directories
> 	  (delq nil
> 		(mapcar
> 		 (lambda (f) (if (file-directory-p f) nil f))
> 		 (nreverse (dired-map-over-marks (dired-get-filename) nil)))))

How about use files-to-attach as an argument? So the function can be
called from other codes too. 

(defun gnus-dired-attach (files-to-attach)
   "Attach dired's marked files to a gnus message composition."
   (interactive
      (list
 	 (delq nil
 	      (mapcar
 		 (lambda (f) (if (file-directory-p f) nil f))
 		 (nreverse (dired-map-over-marks (dired-get-filename) nil))))))
    ...)

ShengHuo



^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: request feedback on new function gnus-dired-attach
  2001-12-15  6:12 ` ShengHuo ZHU
@ 2001-12-15  6:39   ` Benjamin Rutt
  2001-12-15  8:17   ` Benjamin Rutt
  2001-12-15 23:34   ` Benjamin Rutt
  2 siblings, 0 replies; 14+ messages in thread
From: Benjamin Rutt @ 2001-12-15  6:39 UTC (permalink / raw)


ShengHuo ZHU <zsh@cs.rochester.edu> writes:

>> (define-key dired-mode-map [(control c) (control a)] 'gnus-dired-attach)
>>
>>    is somewhat ugly, since we are defining a dired keymap in another
>>    area of code.  Paul Jarc, on the above g.e.g thread, suggested that
>>    we define a gnus-dired minor mode which can contain the keymap.
>>    But I'm not sure if that's better, since ultimately we're still
>>    stealing a possible future dired keybinding (C-c C-a currently
>>    isn't defined in dired-mode).  Maybe that last line should simply
>>    go in users ~/.gnus so the users control the keybinding override?
>
> Why not do both?  We can steal a special (or customizable) prefix for
> gnus-dired minor mode.  Users still can set C-c C-a in dired-mode-map
> to the function.  This would be less intrusive.

OK, I'll work on defining a gnus-dired minor mode.

>> 3) whether you think this should exist as a separate file that isn't
>>    included in gnus.
>
> It is better to add a separate file, say gnus-dired.el, for gnus-dired
> minor mode. If you'd like to add your code to Gnus package, you'd
> better send an assignment form to FSF (unless you've signed the form).
> I can send you the request form.

Yes, I'd like it to be included with gnus.  I will be happy to sign
the assignment request form for the FSF, just let me know what I need
to do to get that accomplished.

> In addition, I have a piece of code to open file (in dired-mode)
> according to mailcap.  I'd like to include it too.

Sure, please send your code to me and I will integrate it into the new
file gnus-dired.el.  The file can then be used for any purpose where
gnus and dired meet.

> How about use files-to-attach as an argument? So the function can be
> called from other codes too. 
>
> (defun gnus-dired-attach (files-to-attach)
>    "Attach dired's marked files to a gnus message composition."
>    (interactive
>       (list
>  	 (delq nil
>  	      (mapcar
>  		 (lambda (f) (if (file-directory-p f) nil f))
>  		 (nreverse (dired-map-over-marks (dired-get-filename) nil))))))
>     ...)

That looks very nice, I will make that change.  Thanks,
-- 
Benjamin



^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: request feedback on new function gnus-dired-attach
  2001-12-15  6:12 ` ShengHuo ZHU
  2001-12-15  6:39   ` Benjamin Rutt
@ 2001-12-15  8:17   ` Benjamin Rutt
  2001-12-15 23:34   ` Benjamin Rutt
  2 siblings, 0 replies; 14+ messages in thread
From: Benjamin Rutt @ 2001-12-15  8:17 UTC (permalink / raw)


NOTE: my outgoing mail has apparently been arriving on this mailing
list out-of-order lately, hopefully that won't cause any confusion for
anyone.

ShengHuo ZHU <zsh@cs.rochester.edu> writes:

> It is better to add a separate file, say gnus-dired.el, for gnus-dired
> minor mode. 

Here is my effort in this direction.  Feedback appreciated.  A few
things I'm not sure about:

1) did I define the `gnus-dired-mode-map' keymap correctly?  (I know
   you mentioned something about stealing a special (or customizable)
   prefix.  I just stuck C-c C-a in there.

2) I didn't think there should be a mode line string for this minor
   mode, so I left it empty.

Here begins the file gnus-dired.el:

;;; gnus-dired.el --- utility functions where dired and gnus meet

;; Copyright (C) 1996, 1997, 1998, 1999, 2001
;;        Free Software Foundation, Inc.

;; Author: Benjamin Rutt <brutt@bloomington.in.us>
;; Keywords: news, extensions

;; This file 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 file 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, Inc., 59 Temple Place - Suite 330,
;; Boston, MA 02111-1307, USA.

;;; Commentary:

;; Provide utility functions for intersections of gnus and dired.

;;; Code:

(defvar gnus-dired-mode nil
  "Minor mode for intersections of gnus and dired.")

(defvar gnus-dired-mode-map nil)

(unless gnus-dired-mode-map
  (setq gnus-dired-mode-map (make-sparse-keymap))

  (gnus-define-keys gnus-dired-mode-map
    "\C-c\C-a" gnus-dired-attach))

(defun gnus-dired-mode (&optional arg)
  "Minor mode for intersections of gnus and dired.

\\{gnus-dired-mode-map}"
  (interactive "P")
  (when (eq major-mode 'dired-mode)
    (set (make-local-variable 'gnus-dired-mode)
	 (if (null arg) (not gnus-dired-mode)
	   (> (prefix-numeric-value arg) 0)))
    (when gnus-dired-mode
      (gnus-add-minor-mode 'gnus-dired-mode "" gnus-dired-mode-map)
      (gnus-run-hooks 'gnus-dired-mode-hook))))

;; Method to attach files to a gnus composition.
(defun gnus-dired-attach (files-to-attach)
  "Attach dired's marked files to a gnus message composition.
If called non-interactively, FILES-TO-ATTACH should be a list of
filenames."
  (interactive
   (list
    (delq nil
	  (mapcar
	   ;; don't attach directories
	   (lambda (f) (if (file-directory-p f) nil f))
	   (nreverse (dired-map-over-marks (dired-get-filename) nil))))))
  (let ((destination nil)
	(files-str nil)
	(bufs nil))
    ;; warn if user tries to attach without any files marked 
    (if (null files-to-attach)
	(message "No files marked to attach")
      (setq files-str
	    (mapconcat
	     (lambda (f) (file-name-nondirectory f))
	     files-to-attach ", "))
      (setq bufs (message-buffers))
    
      ;; set up destination message buffer
      (if (and bufs
	       (y-or-n-p "Attach files to existing message buffer? "))
	  (setq destination
		(if (= (length bufs) 1)
		    (get-buffer (car bufs))
		  (completing-read "Attach to which message buffer: "
				   (mapcar
				    (lambda (b)
				      (cons b (get-buffer b)))
				    bufs)
				   nil t)))
	;; setup a new gnus message buffer
	(gnus-setup-message 'message (message-mail))
	(setq destination (current-buffer)))

      ;; set buffer to destination buffer, and attach files
      (set-buffer destination)
      (goto-char (point-max))		;attach at end of buffer
      (while files-to-attach
	(mml-attach-file (car files-to-attach)
			 (or (mm-default-file-encoding (car files-to-attach))
			     "application/octet-stream") nil)
	(setq files-to-attach (cdr files-to-attach)))
      (message "Attached file(s) %s" files-str))))

(provide 'gnus-dired)
;;; gnus-dired.el ends here

-- 
Benjamin




^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: request feedback on new function gnus-dired-attach
  2001-12-15  6:12 ` ShengHuo ZHU
  2001-12-15  6:39   ` Benjamin Rutt
  2001-12-15  8:17   ` Benjamin Rutt
@ 2001-12-15 23:34   ` Benjamin Rutt
  2001-12-29  0:40     ` Lars Magne Ingebrigtsen
  2 siblings, 1 reply; 14+ messages in thread
From: Benjamin Rutt @ 2001-12-15 23:34 UTC (permalink / raw)


ShengHuo ZHU <zsh@cs.rochester.edu> writes:

> In addition, I have a piece of code to open file (in dired-mode)
> according to mailcap.  I'd like to include it too.

Here is my latest version of gnus-dired.el, with your code included.
I think it's getting pretty close.  I know I've sent a lot of messages
to this group this weekend, but this should be the last message on
this subject unless some changes need to be made to the file.  Let me
know if you think anything should be changed (particularly the
key bindings).  Also, I added a bunch of (require ...) statements at
the beginning of the file.  It is better to maintain a set of
autoloads for every library function you use?

I hope you don't mind, I changed the name of your function from
`dired-find-file-mailcap' to `gnus-dired-find-file-mailcap', since it
is going into a file with the same prefix.  Also, I added some output
to the echo area just before you view a file based on your ~/.mailcap.
If you don't like either of these changes please let me know, I don't
want to offend you by modifying your code.  (i.e. feel free to change
it back if you wish.)

Here beings the code:

;;; gnus-dired.el --- utility functions where dired and gnus meet

;; Copyright (C) 1996, 1997, 1998, 1999, 2001
;;        Free Software Foundation, Inc.

;; Author: Benjamin Rutt <brutt@bloomington.in.us>
;; Keywords: mail, news, extensions

;; This file 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 file 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, Inc., 59 Temple Place - Suite 330,
;; Boston, MA 02111-1307, USA.

;;; Commentary:

;; Contributors:
;;     Shenghuo Zhu <zsh@cs.rochester.edu>

;; This package provides utility functions for intersections of gnus
;; and dired.

;;; Code:

(require 'dired)
(require 'gnus-ems)
(require 'gnus-msg)
(require 'gnus-util)
(require 'message)
(require 'mm-encode)
(require 'mml)

(defvar gnus-dired-mode nil
  "Minor mode for intersections of gnus and dired.")

(defvar gnus-dired-mode-map nil)

(unless gnus-dired-mode-map
  (setq gnus-dired-mode-map (make-sparse-keymap))

  (gnus-define-keys gnus-dired-mode-map
    "\C-c\C-a" gnus-dired-attach
    "\C-c\C-f" gnus-dired-find-file-mailcap))

(defun gnus-dired-mode (&optional arg)
  "Minor mode for intersections of gnus and dired.

\\{gnus-dired-mode-map}"
  (interactive "P")
  (when (eq major-mode 'dired-mode)
    (set (make-local-variable 'gnus-dired-mode)
	 (if (null arg) (not gnus-dired-mode)
	   (> (prefix-numeric-value arg) 0)))
    (when gnus-dired-mode
      (gnus-add-minor-mode 'gnus-dired-mode "" gnus-dired-mode-map)
      (gnus-run-hooks 'gnus-dired-mode-hook))))

;; Method to attach files to a gnus composition.
(defun gnus-dired-attach (files-to-attach)
  "Attach dired's marked files to a gnus message composition.
If called non-interactively, FILES-TO-ATTACH should be a list of
filenames."
  (interactive
   (list
    (delq nil
	  (mapcar
	   ;; don't attach directories
	   (lambda (f) (if (file-directory-p f) nil f))
	   (nreverse (dired-map-over-marks (dired-get-filename) nil))))))
  (let ((destination nil)
	(files-str nil)
	(bufs nil))
    ;; warn if user tries to attach without any files marked 
    (if (null files-to-attach)
	(error "No files to attach")
      (setq files-str
	    (mapconcat
	     (lambda (f) (file-name-nondirectory f))
	     files-to-attach ", "))
      (setq bufs (message-buffers))
    
      ;; set up destination message buffer
      (if (and bufs
	       (y-or-n-p "Attach files to existing message buffer? "))
	  (setq destination
		(if (= (length bufs) 1)
		    (get-buffer (car bufs))
		  (completing-read "Attach to which message buffer: "
				   (mapcar
				    (lambda (b)
				      (cons b (get-buffer b)))
				    bufs)
				   nil t)))
	;; setup a new gnus message buffer
	(gnus-setup-message 'message (message-mail))
	(setq destination (current-buffer)))

      ;; set buffer to destination buffer, and attach files
      (set-buffer destination)
      (goto-char (point-max))		;attach at end of buffer
      (while files-to-attach
	(mml-attach-file (car files-to-attach)
			 (or (mm-default-file-encoding (car files-to-attach))
			     "application/octet-stream") nil)
	(setq files-to-attach (cdr files-to-attach)))
      (message "Attached file(s) %s" files-str))))

(autoload 'mailcap-parse-mailcaps "mailcap" "" t)

(defun gnus-dired-find-file-mailcap (&optional file-name arg)
  "In dired, visit FILE-NAME according to the mailcap file.
If ARG is non-nil, open it in a new buffer."
  (interactive (list
		(file-name-sans-versions (dired-get-filename) t)
		current-prefix-arg))
  (mailcap-parse-mailcaps)
  (if (and (file-exists-p file-name)
	   (not (file-directory-p file-name)))
      (let (mime-type method)
	(if (and (not arg)
		 (string-match "\\.[^\\.]+$" file-name)
		 (setq mime-type
		       (mailcap-extension-to-mime 
			(match-string 0 file-name)))
		 (stringp 
		  (setq method
			(cdr (assoc 'viewer 
				    (car (mailcap-mime-info mime-type 
							    'all)))))))
	    (let ((view-command (mm-mailcap-command method file-name nil)))
	      (message "viewing via %s" view-command)
	      (start-process "*display*"
			   nil
			   shell-file-name
			   shell-command-switch
			   view-command))
	  (find-file file-name)))
    (if (file-symlink-p file-name)
	(error "File is a symlink to a nonexistent target")
      (error "File no longer exists; type `g' to update Dired buffer"))))

(provide 'gnus-dired)
;;; gnus-dired.el ends here

-- 
Benjamin




^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: request feedback on new function gnus-dired-attach
  2001-12-15 23:34   ` Benjamin Rutt
@ 2001-12-29  0:40     ` Lars Magne Ingebrigtsen
  2001-12-31  7:06       ` Benjamin Rutt
  2002-02-02  1:25       ` Benjamin Rutt
  0 siblings, 2 replies; 14+ messages in thread
From: Lars Magne Ingebrigtsen @ 2001-12-29  0:40 UTC (permalink / raw)


Benjamin Rutt <rutt+news@cis.ohio-state.edu> writes:

> Here is my latest version of gnus-dired.el, with your code included.
> I think it's getting pretty close. 

Hey; looks good.  Has the FSF been in touch with you (or vice versa)
about paperwork?

Hm...  Where did I put the FSF maintainer/assignment kit thingie...
Anybody recall what that's called?  The manual?

-- 
(domestic pets only, the antidote for overdose, milk.)
   larsi@gnus.org * Lars Magne Ingebrigtsen



^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: request feedback on new function gnus-dired-attach
  2001-12-29  0:40     ` Lars Magne Ingebrigtsen
@ 2001-12-31  7:06       ` Benjamin Rutt
  2001-12-31  7:47         ` Paul Jarc
  2002-01-19 19:12         ` Lars Magne Ingebrigtsen
  2002-02-02  1:25       ` Benjamin Rutt
  1 sibling, 2 replies; 14+ messages in thread
From: Benjamin Rutt @ 2001-12-31  7:06 UTC (permalink / raw)


Lars Magne Ingebrigtsen <larsi@gnus.org> writes:

> Benjamin Rutt <rutt+news@cis.ohio-state.edu> writes:
>
>> Here is my latest version of gnus-dired.el, with your code included.
>> I think it's getting pretty close. 
>
> Hey; looks good.  Has the FSF been in touch with you (or vice versa)
> about paperwork?

After Shenghuo sent me an email form, I sent it to
fsf-records@gnu.org.  That's the last thing I've done on this matter,
and it was several weeks ago, so I was wondering what the next phase
should be.  I'm guessing there is something more to do?  (wait for
something to arrive via snail mail which I then sign and return?)
Thanks,
-- 
Benjamin



^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: request feedback on new function gnus-dired-attach
  2001-12-31  7:06       ` Benjamin Rutt
@ 2001-12-31  7:47         ` Paul Jarc
  2002-01-19 19:12         ` Lars Magne Ingebrigtsen
  1 sibling, 0 replies; 14+ messages in thread
From: Paul Jarc @ 2001-12-31  7:47 UTC (permalink / raw)


Benjamin Rutt <rutt+news@cis.ohio-state.edu> wrote:
> After Shenghuo sent me an email form, I sent it to
> fsf-records@gnu.org.  That's the last thing I've done on this matter,
> and it was several weeks ago, so I was wondering what the next phase
> should be.  I'm guessing there is something more to do?  (wait for
> something to arrive via snail mail which I then sign and return?)

That's how it worked for me.  Note that they don't normally email you
a confirmation when your paperwork arrives, so if it gets lost in the
mail on the way back to them, you'd never know unless you ask.


paul



^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: request feedback on new function gnus-dired-attach
  2001-12-31  7:06       ` Benjamin Rutt
  2001-12-31  7:47         ` Paul Jarc
@ 2002-01-19 19:12         ` Lars Magne Ingebrigtsen
  2002-01-20  0:39           ` Benjamin Rutt
  1 sibling, 1 reply; 14+ messages in thread
From: Lars Magne Ingebrigtsen @ 2002-01-19 19:12 UTC (permalink / raw)


Benjamin Rutt <rutt+news@cis.ohio-state.edu> writes:

> After Shenghuo sent me an email form, I sent it to
> fsf-records@gnu.org.  That's the last thing I've done on this matter,
> and it was several weeks ago, so I was wondering what the next phase
> should be.  I'm guessing there is something more to do?  (wait for
> something to arrive via snail mail which I then sign and return?)

That's what's supposed to happen.  If you still haven't received the
form, then we should query fsf-records...

-- 
(domestic pets only, the antidote for overdose, milk.)
   larsi@gnus.org * Lars Magne Ingebrigtsen



^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: request feedback on new function gnus-dired-attach
  2002-01-19 19:12         ` Lars Magne Ingebrigtsen
@ 2002-01-20  0:39           ` Benjamin Rutt
  2002-01-20  0:52             ` Lars Magne Ingebrigtsen
  0 siblings, 1 reply; 14+ messages in thread
From: Benjamin Rutt @ 2002-01-20  0:39 UTC (permalink / raw)


Lars Magne Ingebrigtsen <larsi@gnus.org> writes:

> Benjamin Rutt <rutt+news@cis.ohio-state.edu> writes:
>
>> After Shenghuo sent me an email form, I sent it to
>> fsf-records@gnu.org.  That's the last thing I've done on this matter,
>> and it was several weeks ago, so I was wondering what the next phase
>> should be.  I'm guessing there is something more to do?  (wait for
>> something to arrive via snail mail which I then sign and return?)
>
> That's what's supposed to happen.  If you still haven't received the
> form, then we should query fsf-records...

As of today (Sat Jan 19, 2002), I still haven't received any form via
snail mail.  So, maybe we should query fsf-records, although I'm not
sure how to do that.  I assume you know what to do on this one, Lars?
Thanks.
-- 
Benjamin



^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: request feedback on new function gnus-dired-attach
  2002-01-20  0:39           ` Benjamin Rutt
@ 2002-01-20  0:52             ` Lars Magne Ingebrigtsen
  0 siblings, 0 replies; 14+ messages in thread
From: Lars Magne Ingebrigtsen @ 2002-01-20  0:52 UTC (permalink / raw)


Benjamin Rutt <rutt+news@cis.ohio-state.edu> writes:

> As of today (Sat Jan 19, 2002), I still haven't received any form via
> snail mail.  So, maybe we should query fsf-records, although I'm not
> sure how to do that.  I assume you know what to do on this one, Lars?

I'll send some e-mails and ask.

-- 
(domestic pets only, the antidote for overdose, milk.)
   larsi@gnus.org * Lars Magne Ingebrigtsen



^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: request feedback on new function gnus-dired-attach
  2001-12-29  0:40     ` Lars Magne Ingebrigtsen
  2001-12-31  7:06       ` Benjamin Rutt
@ 2002-02-02  1:25       ` Benjamin Rutt
  2002-02-02  6:38         ` ShengHuo ZHU
  1 sibling, 1 reply; 14+ messages in thread
From: Benjamin Rutt @ 2002-02-02  1:25 UTC (permalink / raw)


Lars Magne Ingebrigtsen <larsi@gnus.org> writes:

> Benjamin Rutt <rutt+news@cis.ohio-state.edu> writes:
>
>> Here is my latest version of gnus-dired.el, with your code included.
>> I think it's getting pretty close. 
>
> Hey; looks good.  Has the FSF been in touch with you (or vice versa)
> about paperwork?

I have now signed the relevant papers for the project 'Emacs Gnus' and
sent them back via snail mail to the FSF as of Monday of this week.
Now that the copyright issues are in order, I guess it is OK to look
at gnus-dired.el again.

I have pasted the latest version of gnus-dired.el below.  (The only
parts I've changed since it was last posted a month ago are a few
tidbits in the commentary, and also I added the convenience function
`turn-on-gnus-dired-mode'.)  Enabling gnus-dired now requires the
following lines in your ~/.gnus:

(require 'gnus-dired)
(add-hook 'dired-mode-hook 'turn-on-gnus-dired-mode)

If there's a simpler way to turn it on, I'm all ears.  I'm guessing
not everyone would want to use this package (which also has the effect
of slightly polluting dired key bindings), so probably the above hook
should never be automatically added when gnus starts.

Feedback/criticism is welcome.

Also, if this file gets added to gnus, I'll be happy to write some
info documentation.  I think a new node "(gnus) Dired" under the
"Various" heirarchy is the proper place for a few choice words.  Is
there anywhere which might be better?

Thanks!  Here begins the code:

;;; gnus-dired.el --- utility functions where gnus and dired meet

;; Copyright (C) 1996, 1997, 1998, 1999, 2001
;;        Free Software Foundation, Inc.

;; Authors: Benjamin Rutt <brutt@bloomington.in.us>,
;;          Shenghuo Zhu <zsh@cs.rochester.edu>
;; Keywords: mail, news, extensions

;; This file 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 file 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, Inc., 59 Temple Place - Suite 330,
;; Boston, MA 02111-1307, USA.

;;; Commentary:

;; This package provides utility functions for intersections of gnus
;; and dired.  To enable the gnus-dired-mode minor mode which will
;; have the effect of installing keybindings in dired-mode, place the
;; following in your ~/.gnus:

;; (require 'gnus-dired)
;; (add-hook 'dired-mode-hook 'turn-on-gnus-dired-mode)

;; Note that if you visit dired buffers before your ~/.gnus file has
;; been read, those dired buffers won't have the keybindings in
;; effect.  To get around that problem, you may want to add the above
;; statements to your ~/.emacs instead.

;;; Code:

(require 'dired)
(require 'gnus-ems)
(require 'gnus-msg)
(require 'gnus-util)
(require 'message)
(require 'mm-encode)
(require 'mml)

(defvar gnus-dired-mode nil
  "Minor mode for intersections of gnus and dired.")

(defvar gnus-dired-mode-map nil)

(unless gnus-dired-mode-map
  (setq gnus-dired-mode-map (make-sparse-keymap))

  (gnus-define-keys gnus-dired-mode-map
    "\C-c\C-a" gnus-dired-attach
    "\C-c\C-f" gnus-dired-find-file-mailcap))

(defun gnus-dired-mode (&optional arg)
  "Minor mode for intersections of gnus and dired.

\\{gnus-dired-mode-map}"
  (interactive "P")
  (when (eq major-mode 'dired-mode)
    (set (make-local-variable 'gnus-dired-mode)
	 (if (null arg) (not gnus-dired-mode)
	   (> (prefix-numeric-value arg) 0)))
    (when gnus-dired-mode
      (gnus-add-minor-mode 'gnus-dired-mode "" gnus-dired-mode-map)
      (gnus-run-hooks 'gnus-dired-mode-hook))))

;; Convenience method to turn on gnus-dired-mode.
(defsubst turn-on-gnus-dired-mode ()
  (gnus-dired-mode 1))

;; Method to attach files to a gnus composition.
(defun gnus-dired-attach (files-to-attach)
  "Attach dired's marked files to a gnus message composition.
If called non-interactively, FILES-TO-ATTACH should be a list of
filenames."
  (interactive
   (list
    (delq nil
	  (mapcar
	   ;; don't attach directories
	   (lambda (f) (if (file-directory-p f) nil f))
	   (nreverse (dired-map-over-marks (dired-get-filename) nil))))))
  (let ((destination nil)
	(files-str nil)
	(bufs nil))
    ;; warn if user tries to attach without any files marked 
    (if (null files-to-attach)
	(error "No files to attach")
      (setq files-str
	    (mapconcat
	     (lambda (f) (file-name-nondirectory f))
	     files-to-attach ", "))
      (setq bufs (message-buffers))
    
      ;; set up destination message buffer
      (if (and bufs
	       (y-or-n-p "Attach files to existing message buffer? "))
	  (setq destination
		(if (= (length bufs) 1)
		    (get-buffer (car bufs))
		  (completing-read "Attach to which message buffer: "
				   (mapcar
				    (lambda (b)
				      (cons b (get-buffer b)))
				    bufs)
				   nil t)))
	;; setup a new gnus message buffer
	(gnus-setup-message 'message (message-mail))
	(setq destination (current-buffer)))

      ;; set buffer to destination buffer, and attach files
      (set-buffer destination)
      (goto-char (point-max))		;attach at end of buffer
      (while files-to-attach
	(mml-attach-file (car files-to-attach)
			 (or (mm-default-file-encoding (car files-to-attach))
			     "application/octet-stream") nil)
	(setq files-to-attach (cdr files-to-attach)))
      (message "Attached file(s) %s" files-str))))

(autoload 'mailcap-parse-mailcaps "mailcap" "" t)

(defun gnus-dired-find-file-mailcap (&optional file-name arg)
  "In dired, visit FILE-NAME according to the mailcap file.
If ARG is non-nil, open it in a new buffer."
  (interactive (list
		(file-name-sans-versions (dired-get-filename) t)
		current-prefix-arg))
  (mailcap-parse-mailcaps)
  (if (and (file-exists-p file-name)
	   (not (file-directory-p file-name)))
      (let (mime-type method)
	(if (and (not arg)
		 (string-match "\\.[^\\.]+$" file-name)
		 (setq mime-type
		       (mailcap-extension-to-mime 
			(match-string 0 file-name)))
		 (stringp 
		  (setq method
			(cdr (assoc 'viewer 
				    (car (mailcap-mime-info mime-type 
							    'all)))))))
	    (let ((view-command (mm-mailcap-command method file-name nil)))
	      (message "viewing via %s" view-command)
	      (start-process "*display*"
			     nil
			     shell-file-name
			     shell-command-switch
			     view-command))
	  (find-file file-name)))
    (if (file-symlink-p file-name)
	(error "File is a symlink to a nonexistent target")
      (error "File no longer exists; type `g' to update Dired buffer"))))

(provide 'gnus-dired)
;;; gnus-dired.el ends here

-- 
Benjamin




^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: request feedback on new function gnus-dired-attach
  2002-02-02  1:25       ` Benjamin Rutt
@ 2002-02-02  6:38         ` ShengHuo ZHU
  0 siblings, 0 replies; 14+ messages in thread
From: ShengHuo ZHU @ 2002-02-02  6:38 UTC (permalink / raw)


Benjamin Rutt <rutt+news@cis.ohio-state.edu> writes:

> Lars Magne Ingebrigtsen <larsi@gnus.org> writes:
>
>> Benjamin Rutt <rutt+news@cis.ohio-state.edu> writes:
>>
>>> Here is my latest version of gnus-dired.el, with your code included.
>>> I think it's getting pretty close. 
>>
>> Hey; looks good.  Has the FSF been in touch with you (or vice versa)
>> about paperwork?
>
> I have now signed the relevant papers for the project 'Emacs Gnus' and
> sent them back via snail mail to the FSF as of Monday of this week.
> Now that the copyright issues are in order, I guess it is OK to look
> at gnus-dired.el again.

I've added it into the CVS depository.

ShengHuo



^ permalink raw reply	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2002-02-02  6:38 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-12-15  0:19 request feedback on new function gnus-dired-attach Benjamin Rutt
2001-12-15  5:25 ` Benjamin Rutt
2001-12-15  6:12 ` ShengHuo ZHU
2001-12-15  6:39   ` Benjamin Rutt
2001-12-15  8:17   ` Benjamin Rutt
2001-12-15 23:34   ` Benjamin Rutt
2001-12-29  0:40     ` Lars Magne Ingebrigtsen
2001-12-31  7:06       ` Benjamin Rutt
2001-12-31  7:47         ` Paul Jarc
2002-01-19 19:12         ` Lars Magne Ingebrigtsen
2002-01-20  0:39           ` Benjamin Rutt
2002-01-20  0:52             ` Lars Magne Ingebrigtsen
2002-02-02  1:25       ` Benjamin Rutt
2002-02-02  6:38         ` ShengHuo ZHU

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).