From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Tom Roche , Newsgroups: gmane.emacs.help Subject: Re: [emacs-lisp newbie] print-something() -> clipboard? Date: Sun, 20 May 2012 16:27:58 -0400 Message-ID: <87boli1ttd.fsf@pobox.com> References: <4FB74988.9000404@easy-emacs.de> <87r4uhxof8.fsf@pobox.com> Reply-To: help-gnu-emacs@gnu.org, Tom Roche NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Trace: dough.gmane.org 1337545323 19612 80.91.229.3 (20 May 2012 20:22:03 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Sun, 20 May 2012 20:22:03 +0000 (UTC) To: help-gnu-emacs@gnu.org, Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Sun May 20 22:22:03 2012 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1SWCda-0007IN-4o for geh-help-gnu-emacs@m.gmane.org; Sun, 20 May 2012 22:21:58 +0200 Original-Received: from localhost ([::1]:45989 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SWCdZ-0001mI-5i for geh-help-gnu-emacs@m.gmane.org; Sun, 20 May 2012 16:21:57 -0400 Original-Received: from eggs.gnu.org ([208.118.235.92]:58134) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SWCdT-0001ll-47 for help-gnu-emacs@gnu.org; Sun, 20 May 2012 16:21:52 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1SWCdR-0005u2-9u for help-gnu-emacs@gnu.org; Sun, 20 May 2012 16:21:50 -0400 Original-Received: from b-pb-sasl-quonix.pobox.com ([208.72.237.35]:37018 helo=smtp.pobox.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SWCdR-0005ts-18 for help-gnu-emacs@gnu.org; Sun, 20 May 2012 16:21:49 -0400 Original-Received: from smtp.pobox.com (unknown [127.0.0.1]) by b-sasl-quonix.pobox.com (Postfix) with ESMTP id DDFB78954; Sun, 20 May 2012 16:21:44 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=pobox.com; h=from:to :subject:in-reply-to:references:reply-to:date:message-id :mime-version:content-type:content-transfer-encoding; s=sasl; bh=fUsDGENXwd9ww9QdoVCIcQdZTBI=; b=hCfwf7AxGAmQIvvrg6aEQeGSouqQ bMSp5pVCOPaCGFFe//8ilkMDNxa34LzMp3IxqyerFEc3RTOSDmQlpf5tve6xzvl7 IB4M+LbVDaB1PQuOZnXYDWTtleQNe8q3bOFG8U7n+Zh+jTgR6mWmhk+5wvsZk3o4 Akn71+wtGQKVv98= DomainKey-Signature: a=rsa-sha1; c=nofws; d=pobox.com; h=from:to:subject :in-reply-to:references:reply-to:date:message-id:mime-version :content-type:content-transfer-encoding; q=dns; s=sasl; b=C0NFzm gv/I0Dlcw/lqthij1/knm2GP/ywxv9e8A0D/Ili6KlOxYs0PTz2K1MuKb4lJWWZ9 A4RLLEqL7E54vreb3xndV9u62/t1uEK84WDt4GSxTQi6fd8YPUfLSjNA/AmwIH4f pq93MzPVjr+Pkmpr56rYG0jMaWP+mjDhJEJeo= Original-Received: from b-pb-sasl-quonix.pobox.com (unknown [127.0.0.1]) by b-sasl-quonix.pobox.com (Postfix) with ESMTP id D42368953; Sun, 20 May 2012 16:21:44 -0400 (EDT) Original-Received: from tlrPanP5.pobox.com (unknown [66.57.63.73]) (using TLSv1 with cipher DHE-RSA-AES128-SHA (128/128 bits)) (No client certificate requested) by b-sasl-quonix.pobox.com (Postfix) with ESMTPSA id 3F2628951; Sun, 20 May 2012 16:21:44 -0400 (EDT) In-Reply-To: User-Agent: GNU Emacs 24.1.50.1 (x86_64-pc-linux-gnu, GTK+ Version 2.20.1) X-Pobox-Relay-ID: 6AFA218A-A2B9-11E1-967F-FC762E706CDE-07218935!b-pb-sasl-quonix.pobox.com X-detected-operating-system: by eggs.gnu.org: Solaris 10 (beta) X-Received-From: 208.72.237.35 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:84907 Archived-At: Tom Roche 18.05.2012 21:46 >>> (defun print-buffer-name () >>> "Print (at point) the current buffer's name." >>> (interactive "*") ; abort if buffer is read-only >>> (insert (buffer-name (window-buffer (minibuffer-selected-window))))) >>> (global-set-key "\C-pb" 'print-buffer-name) ... >>> I'd like to have the option to "print" the datum to the clipboard. >>> How can I (easily :-) do that? Andreas R=C3=B6hler Sat, 19 May 2012 09:19:36 +0200 >> (defun yank-date-clipboard () >> "Insert into the kill-ring, at X also into the clipboard." >> (interactive) >> (kill-new (format-time-string "%Y%m%d"))) Drew Adams Sun, 20 May 2012 12:20:09 -0700 > (defun foo (&optional arg) > "..." > (interactive "P") > (let ((bn ...)) > (if arg > (insert bn) > (kill-new bn)))) Thanks! I probably should `let`, but this works: (defun print-buffer-name (&optional arg) "Print (at point) the current buffer's name, or to clipboard with prefix." (interactive "P") ; sets first arg to the raw command prefix (setq bn (buffer-name (window-buffer (minibuffer-selected-window)))) (if arg (kill-new bn) (insert bn))) (global-set-key "\C-pb" 'print-buffer-name) thanks again, Tom Roche