From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=DKIM_INVALID,DKIM_SIGNED, RCVD_IN_DNSWL_MED,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 18140 invoked from network); 24 May 2021 06:30:05 -0000 Received: from mx1.math.uh.edu (129.7.128.32) by inbox.vuxu.org with ESMTPUTF8; 24 May 2021 06:30:05 -0000 Received: from lists1.math.uh.edu ([129.7.128.208]) by mx1.math.uh.edu with esmtps (TLS1.3) tls TLS_AES_256_GCM_SHA384 (Exim 4.94) (envelope-from ) id 1ll46F-0067rF-A5 for ml@inbox.vuxu.org; Mon, 24 May 2021 01:30:03 -0500 Received: from localhost ([127.0.0.1] helo=lists.math.uh.edu) by lists1.math.uh.edu with smtp (Exim 4.94) (envelope-from ) id 1ll46E-00Fzom-Ns for ml@inbox.vuxu.org; Mon, 24 May 2021 01:30:02 -0500 Received: from mx2.math.uh.edu ([129.7.128.33]) by lists1.math.uh.edu with esmtps (TLS1.3) tls TLS_AES_256_GCM_SHA384 (Exim 4.94) (envelope-from ) id 1ll46C-00Fzoe-BH for ding@lists.math.uh.edu; Mon, 24 May 2021 01:30:00 -0500 Received: from quimby.gnus.org ([95.216.78.240]) by mx2.math.uh.edu with esmtps (TLS1.3) tls TLS_AES_256_GCM_SHA384 (Exim 4.94) (envelope-from ) id 1ll469-00510M-VI for ding@lists.math.uh.edu; Mon, 24 May 2021 01:29:59 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnus.org; s=20200322; h=Content-Transfer-Encoding:Content-Type:Mime-Version:References :Message-ID:Date:Subject:From:To:Sender:Reply-To:Cc:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:In-Reply-To:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=i8u4md/rAcmDEldAmIuKTXnv8BPVeRe5iVPC+q/+wsA=; b=F+PQo+cNYYSF5EUXeU8qXMR68/ UjHCh4Pqi2z7KqZlKvMMUJczE9k/yCdTHyOENnPA2hwt9vPaBp6K1Cyo4z3vee7r0H2x2zs+r+h7l 1Pjguie5WPWnjMZC7S67AYCTlPhExZCtQ6KXBXeWSgjJmNsJMcDocvCfrzvx7MknI0zM=; Received: from ciao.gmane.io ([116.202.254.214]) by quimby.gnus.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1ll463-00072s-7o for ding@gnus.org; Mon, 24 May 2021 08:29:53 +0200 Received: from list by ciao.gmane.io with local (Exim 4.92) (envelope-from ) id 1ll461-0001tW-TW for ding@gnus.org; Mon, 24 May 2021 08:29:49 +0200 X-Injected-Via-Gmane: http://gmane.org/ Mail-Followup-To: ding@gnus.org To: ding@gnus.org From: Uwe Brauer Subject: Re: my attach this buffer Date: Mon, 24 May 2021 08:29:43 +0200 Message-ID: <87mtsk8x0o.fsf@mat.ucm.es> References: <87fsyen0oz.fsf@mat.ucm.es> <87lf86ver1.fsf@dick> <87zgwmk5pv.fsf@mat.ucm.es> <87k0nqr21q.fsf@ericabrahamsen.net> <87lf859mz9.fsf@mat.ucm.es> <87h7itxhwf.fsf@zoho.eu> Mime-Version: 1.0 Content-Type: text/plain Content-Transfer-Encoding: quoted-printable User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) Cancel-Lock: sha1:mewaGld0UYD0G5fXIp3To0pH9K0= Mail-Copies-To: never Header: Newsgroups List-ID: Precedence: bulk >>> "EB" =3D=3D Emanuel Berg writes: > Uwe Brauer wrote: >>> You could try `mailcap-file-name-to-mime-type' on the file >>> name, and see if that gets it right often enough to >>> be useful. >>=20 >> Hm I tried (mailcap-file-name-to-mime-type (buffer-file-name >> current-buffer)) but that did not work >>=20 >> I mean=20 >>=20 >> (defun my-attach-this-buffer () >> "Send the whole buffer, funny to note that such a function does not exis= t." >> (interactive) >> (let ((src-buf (buffer-file-name (current-buffer)))) >> (let ((my-mime (mailcap-file-name-to-mime-type (buffer-file-name current= -buffer)))) >> (gnus-summary-post-news) >> (mail-text) >> (mml-attach-buffer src-buf my-mime nil nil) >> (message-goto-to)))) >>=20 >> But it did not work > Are you kidding? :O > Straight gangsta! > (require 'gnus-msg) > (require 'mailcap) > (require 'message) > (require 'mml) > (require 'sndmail) > (defun mail-attach-buffer () > (interactive) > (let*((buf (buffer-file-name (current-buffer))) > (mime (mailcap-file-name-to-mime-type buf)) ) > (gnus-summary-post-news) > (mail-text) > (mml-attach-buffer buf mime) > (message-goto-to) )) Thanks, misplaced brackets and let instead of let*, I copied that code from another one badly. Strangely enough if I fire that function in a matlab file I obtain #part buffer=3D"/home/oub/Annu-Matlab2021/file.m" #/part So mail-cap-file-name-to-mime-type does not work, even though "text/x-matlab" Seems a recognised type. Maybe that is a bug