GNU bug report logs - #36979
Calendar: mention how to copy date

Previous Next

Package: emacs;

Reported by: 積丹尼 Dan Jacobson <jidanni <at> jidanni.org>

Date: Thu, 8 Aug 2019 20:32:02 UTC

Severity: wishlist

Tags: wontfix

Done: Glenn Morris <rgm <at> gnu.org>

Bug is archived. No further changes may be made.

Full log


View this message in rfc822 format

From: Tomas Nordin <tomasn <at> posteo.net>
To: 積丹尼 Dan Jacobson <jidanni <at> jidanni.org>
Cc: 36979 <at> debbugs.gnu.org
Subject: bug#36979: closed (Re: bug#36979: Calendar: mention how to copy date)
Date: Sat, 10 Aug 2019 20:55:43 +0200
積丹尼 Dan Jacobson <jidanni <at> jidanni.org> writes:

>>>>>> "RMS" == Richard Stallman <rms <at> gnu.org> writes:
>
>>> But do mention how to copy things like this rather than just view them.
>
> RMS> How do they get displayed?  Surely there is a way to copy text from there.
> RMS> If they are displayed in the echo area, can you find them in *Messages*?
>
> Yes, but is that the "proper" way to copy them?
> One has to (know to) look in *Messages*, find the line one wants with
> the cursor, and copy that line, no more, no less.
>
> About 10 key strokes, careful positioning needed too.
>
> Clearly "looking in the dumpster for the discarded document."
>
> Thus we see the proper way to copy them has not been implemented yet.

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




This bug report was last modified 5 years and 282 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.