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 14:57:30 -0400 Message-ID: <871ume7k9x.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 1337539892 14037 80.91.229.3 (20 May 2012 18:51:32 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Sun, 20 May 2012 18:51:32 +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 20:51:31 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 1SWBE1-0004Hb-7S for geh-help-gnu-emacs@m.gmane.org; Sun, 20 May 2012 20:51:29 +0200 Original-Received: from localhost ([::1]:36909 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SWBE0-0000Tj-Nl for geh-help-gnu-emacs@m.gmane.org; Sun, 20 May 2012 14:51:28 -0400 Original-Received: from eggs.gnu.org ([208.118.235.92]:42888) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SWBDv-0000Te-Qp for help-gnu-emacs@gnu.org; Sun, 20 May 2012 14:51:25 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1SWBDu-0005Tt-1h for help-gnu-emacs@gnu.org; Sun, 20 May 2012 14:51:23 -0400 Original-Received: from b-pb-sasl-quonix.pobox.com ([208.72.237.35]:41002 helo=smtp.pobox.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SWBDt-0005Sd-P7 for help-gnu-emacs@gnu.org; Sun, 20 May 2012 14:51:21 -0400 Original-Received: from smtp.pobox.com (unknown [127.0.0.1]) by b-sasl-quonix.pobox.com (Postfix) with ESMTP id A4F8E88C1; Sun, 20 May 2012 14:51:17 -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=Gx9KzKFBv6P/P3ziHWaJot+J+L0=; b=s4w7FR598MI0FMZ1+Hfu/GnFC5qB DFzYlS0cLc1XmYU6SV6Xvy5c9c2Wet3DKvDP92f90RAeZCb4RpjnbeTIevVIXhAU n/eZK/Fd7RJzzsIWcvFiNFNk/lmLLFjQ6cVf0cOhRIw9Gjm9DLG7wWH5VXV8YoRC LDaqpJ6TsG0zoSs= 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=Y84g7x 0+HY9H58MzFw4v4i1348TGElw3h9J+Opg/cwF/fLyQX2x26zaIqOixQBE8/PlJkq +VQbY3Fg9NubTYOJ4EHZuNZAhA/LXP2+cy4joYMpEWmmJm+PzPsTDF9qU5qe68if g0Z/hhhYmlsKlOXDCM5VQ2Z22d81+GoJJKf2Q= Original-Received: from b-pb-sasl-quonix.pobox.com (unknown [127.0.0.1]) by b-sasl-quonix.pobox.com (Postfix) with ESMTP id 9C6BC88BF; Sun, 20 May 2012 14:51:17 -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 EF5A588BE; Sun, 20 May 2012 14:51:16 -0400 (EDT) In-Reply-To: <4FB74988.9000404@easy-emacs.de> User-Agent: GNU Emacs 24.1.50.1 (x86_64-pc-linux-gnu, GTK+ Version 2.20.1) X-Pobox-Relay-ID: C8179B2A-A2AC-11E1-B094-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:84904 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"))) Thanks! So now I'm wondering, how can I toggle between insert-to-buffer and insert-to-clipboard semantics? I now have (defun print-buffer-name () "Print (at point) the current buffer's name." (interactive "*") ; abort if buffer is read-only (let ((bn (buffer-name (window-buffer (minibuffer-selected-window))))) (insert bn))) (global-set-key "\C-pb" 'print-buffer-name) (defun print-buffer-name-clipboard () "Print to clipboard the current buffer's name." (interactive "*") ; abort if buffer is read-only (let ((bn (buffer-name (window-buffer (minibuffer-selected-window))))) (kill-new bn))) (global-set-key "\C-pc" 'print-buffer-name-clipboard) but I don't want to define a separate keychord in each case. I want something like (expressed procedurally--unfortunately I currently think in '{}', not '()') if I type [C-p b] (insert bn) else if I type [C-u C-p b] (kill-new bn) Can that be done with one {function, keychord} definition? Or must I have 2, like above? If the latter, how to define [C-u C-p b]? your assistance is appreciated, Tom Roche