emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

master 10ec1a4d7e: New command 'world-clock-copy-time-as-kill'


From: Stefan Kangas
Subject: master 10ec1a4d7e: New command 'world-clock-copy-time-as-kill'
Date: Wed, 5 Oct 2022 10:34:55 -0400 (EDT)

branch: master
commit 10ec1a4d7e940bb6d67108aeb4316bc1f53403a9
Author: Stefan Kangas <stefankangas@gmail.com>
Commit: Stefan Kangas <stefankangas@gmail.com>

    New command 'world-clock-copy-time-as-kill'
    
    * lisp/time.el (world-clock-copy-time-as-kill): New command.
    (world-clock-mode-map): Bind above new command to "w".
---
 etc/NEWS     |  4 ++++
 lisp/time.el | 10 +++++++++-
 2 files changed, 13 insertions(+), 1 deletion(-)

diff --git a/etc/NEWS b/etc/NEWS
index 916abbc436..b616c5382c 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -2699,6 +2699,10 @@ remote host are shown.  Alternatively, the user option
 *** 'outlineify-sticky' command is renamed to 'allout-outlinify-sticky'.
 The old name is still available as an obsolete function alias.
 
+---
+*** New command 'world-clock-copy-time-as-kill' for 'M-x world-clock'.
+It copies the current line into the kill ring.
+
 ---
 *** 'edit-abbrevs' now uses font-locking.
 The new face 'abbrev-table-name' is used to display the abbrev table
diff --git a/lisp/time.el b/lisp/time.el
index e7066cae7a..247d715ab6 100644
--- a/lisp/time.el
+++ b/lisp/time.el
@@ -528,7 +528,15 @@ If the value is t instead of an alist, use the value of
 
 (defvar-keymap world-clock-mode-map
   "n" #'next-line
-  "p" #'previous-line)
+  "p" #'previous-line
+  "w" #'world-clock-copy-time-as-kill)
+
+(defun world-clock-copy-time-as-kill ()
+  "Copy current line into the kill ring."
+  (interactive nil world-clock-mode)
+  (when-let ((str (buffer-substring-no-properties (pos-bol) (pos-eol))))
+    (kill-new str)
+    (message str)))
 
 (define-derived-mode world-clock-mode special-mode "World clock"
   "Major mode for buffer that displays times in various time zones.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]