From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED.blaine.gmane.org!not-for-mail From: Deus Max Newsgroups: gmane.emacs.bugs Subject: bug#36979: closed (Re: bug#36979: Calendar: mention how to copy date) Date: Sun, 11 Aug 2019 14:13:25 +0300 Message-ID: <87a7cgosyy.fsf@aia00054aia.gr> References: <7csgqbl0i6.fsf@fencepost.gnu.org> <87v9v7a3ka.2.fsf@jidanni.org> <87tvarw2d4.5.fsf@jidanni.org> <8736i8yj24.5.fsf@jidanni.org> <8736i86ea8.fsf@fliptop.i-did-not-set--mail-host-address--so-tickle-me> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: blaine.gmane.org; posting-host="blaine.gmane.org:195.159.176.226"; logging-data="8554"; mail-complaints-to="usenet@blaine.gmane.org" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (gnu/linux) Cc: 36979@debbugs.gnu.org To: Tomas Nordin Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Sun Aug 11 13:14:09 2019 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([209.51.188.17]) by blaine.gmane.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1hwlnd-00026r-AF for geb-bug-gnu-emacs@m.gmane.org; Sun, 11 Aug 2019 13:14:09 +0200 Original-Received: from localhost ([::1]:39740 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hwlnc-0004UA-1W for geb-bug-gnu-emacs@m.gmane.org; Sun, 11 Aug 2019 07:14:08 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:52570) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hwlnX-0004Tq-Qs for bug-gnu-emacs@gnu.org; Sun, 11 Aug 2019 07:14:04 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hwlnW-0006BN-Bp for bug-gnu-emacs@gnu.org; Sun, 11 Aug 2019 07:14:03 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:35961) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hwlnW-0006BH-7g for bug-gnu-emacs@gnu.org; Sun, 11 Aug 2019 07:14:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1hwlnW-00073x-1r for bug-gnu-emacs@gnu.org; Sun, 11 Aug 2019 07:14:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Deus Max Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 11 Aug 2019 11:14:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 36979 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: wontfix Original-Received: via spool by 36979-submit@debbugs.gnu.org id=B36979.156552202027098 (code B ref 36979); Sun, 11 Aug 2019 11:14:01 +0000 Original-Received: (at 36979) by debbugs.gnu.org; 11 Aug 2019 11:13:40 +0000 Original-Received: from localhost ([127.0.0.1]:44782 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1hwln9-00072z-Tm for submit@debbugs.gnu.org; Sun, 11 Aug 2019 07:13:40 -0400 Original-Received: from mout.gmx.net ([212.227.17.22]:43107) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1hwln7-00072f-Bs for 36979@debbugs.gnu.org; Sun, 11 Aug 2019 07:13:37 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net; s=badeba3b8450; t=1565522009; bh=1spdt4hi6srNGLx2Lm39bJ9OBCNvmBVtbt0f995mK0E=; h=X-UI-Sender-Class:From:To:Cc:Subject:References:Date:In-Reply-To; b=Kk6BUy2OONZwysSaE2S8oRDr2WUuQCTpU+6EZTZ2vALPUCCPfFn63bEwjBgAskXKF UFilZaZeoWVVknM1i3oT1DLArys5+o3AwD1DirxQB+qUDKbiQzTcxSopbVNESr53tF Jj+RzKFj+sqsHirg+u7549U+B4F7+pCHmZUps/JA= X-UI-Sender-Class: 01bb95c1-4bf8-414a-932a-4f6e2808ef9c Original-Received: from dellcorei5dias ([46.176.231.87]) by mail.gmx.com (mrgmx104 [212.227.17.174]) with ESMTPSA (Nemesis) id 1Mz9Z5-1iHiuo1wrT-00wI7X; Sun, 11 Aug 2019 13:13:29 +0200 In-Reply-To: <8736i86ea8.fsf@fliptop.i-did-not-set--mail-host-address--so-tickle-me> (Tomas Nordin's message of "Sat, 10 Aug 2019 20:55:43 +0200") X-Provags-ID: V03:K1:oGvolhIeTpCoBlxL+aSTq9Bk46FVHgiJg8FhajHxWBkTiEZrXOS R+xjwzFqYtqQrrd+lZP+BsKqcy4HbCxxtsfYbmXgCZFt9guN3q3TSokDXkn8x4CcyjkJCgs r7h3WzB4AWmBXBPQx4bYZX7znRPkFPkZ0xKRFJPR4z2Mt10BDU7TIHbe6gJb+L29q018whh aHgUZTBE0ztPd4APxLfLg== X-UI-Out-Filterresults: notjunk:1;V03:K0:h1E+VU4PMz0=:ExlimTYJFPiYt/ISZgGS8E XXJtf4LQOM7TtWhcEL2emSMyp5WUCtfy3cJDmYPNXIULY7QjDNc2oVIEDom4ATiNK7mT/B8QX DiC6s/Gvbh72lvnuCluI0oejefC3zGabalm92DaK1CEZ7F0biQbE/xnhzxxF2vtN49g0/wGEk UP7lfgyav94tEDCdB+njCiPiN5aFvgjVt0oIYtgyy3IiHl8FaZDX9mwF6rZh5EgJkt/rS/Puz v4YxmzAi4JQZOJAfQiNSlUQqo6lqmvdSoIWQHWWENvT7UWYpxXx5O7Wk4oTih6NUhAlTXtf3m a11nzvl5u+ssMvAU4uN1Qbsrj5WzdalqiFU8aBWGjE9ji7BwynskbBxaJlqCmDhTBCL6N3tlq DOJzhDQvewTi1AjMVdTIc7a1ZmJA/d2nkDio3suPOA1e1GRwq9Eon6YN/wqPzjMKzhOpWK+5d 4/VXXJbDYIND0z8MbYk6R/3YPUhEA1H8zgrfuy9vFopuCZl8c9BhRSYpogTmRPuxJUkYxBcEe 7Iy457gy2t8Qyp8YuzoHtgx3txMREUjyUXyY+TWwBVdwi4bTjeqppVjzNXNF95toXtBbcLX3y DkKn/JwyPLKh8UIyOu5hn8JTD6hdtwmXp2fnc8sKy7qSjUxFZKxzp3fKchXVgMkuNLtPrL4nq hE6ojw7ik7wIrhVRRfnDz1sxmvroJux3lK8fEkRKdg5JmaRoSskcxSj0hWXU1vshgb0CMUt/J KNAfarNydgrE0ly6SaAJQm+Ls3BuO3Fi8HG4KVLhBVUWKTua3+bbgN/zpYEBczvPHjhoMJsJ X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.51.188.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.org gmane.emacs.bugs:164878 Archived-At: On Sat, Aug 10 2019, Tomas Nordin wrote: > > I can add my sympathy for the desire of functionality to add date under > point to the kill ring. I was searching for such a feature at some point > (didn't find it) and wrote this function which I bound to RET in > calendar-mode-map: > > (defun tn-calendar-kill-date (&optional arg) > "Kill new a string based on point in calendar buffer in iso format > > With no prefix ARG, kill the date as an iso date. > With one prefix arg ('C-u'), kill the date as an iso week. > with two prefix arg ('C-u C-u'), kill as both the iso week and date." > (interactive "p") > (let* ((date (calendar-cursor-to-date)) > (encoded-time (encode-time 0 0 0 (nth 1 date) (nth 0 date) (nth 2 date))) > (date-string (format-time-string "%Y-%m-%d" encoded-time)) > (iso-week-string (format-time-string "%gW%V" encoded-time)) > kill-string) > > (cond > ((= arg 4) > (setq kill-string iso-week-string)) > ((= arg 16) > (setq kill-string (format "%s %s" iso-week-string date-string))) > (t > (setq kill-string date-string))) > > (kill-new kill-string) > (message "Put %s to kill-ring" kill-string))) > > Best regards > -- > Tomas Hi Tomas, Great function for it can be very useful thank you. I slightly modified it, so it doesn't blow up when the cursor is not on a date and provides an informative message. ;; Copied from bug#36979 by Tomas Nordin, emacs-bugs maillist. (defun tn-calendar-kill-date (&optional arg) "Kill new a string based on point in calendar buffer in iso format With no prefix ARG, kill the date as an iso date. With one prefix arg ('C-u'), kill the date as an iso week. with two prefix arg ('C-u C-u'), kill as both the iso week and date." (interactive "p") (let ((date (calendar-cursor-to-date t))) (if date ;; date is valid (let* ((encoded-time (encode-time 0 0 0 (nth 1 date) (nth 0 date) (nth 2 date))) (date-string (format-time-string "%Y-%m-%d" encoded-time)) (iso-week-string (format-time-string "%gW%V" encoded-time)) kill-string) (cond ((= arg 4) (setq kill-string iso-week-string)) ((= arg 16) (setq kill-string (format "%s %s" iso-week-string date-string))) (t (setq kill-string date-string))) ;; add to kill ring (kill-new kill-string) (message "Put %s to kill-ring" kill-string)) ;; date is not valid - cursor is not on a date. (message "Not on a date."))))