From bcf418d78366c356ab11d0feba3fd1996782af8f Mon Sep 17 00:00:00 2001 From: marty hiatt Date: Mon, 31 Oct 2022 11:47:03 +0100 Subject: flycheck requires / thingatpt fun --- lisp/mastodon.el | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'lisp/mastodon.el') diff --git a/lisp/mastodon.el b/lisp/mastodon.el index bc624d9..a5ba9e4 100644 --- a/lisp/mastodon.el +++ b/lisp/mastodon.el @@ -37,6 +37,8 @@ (require 'mastodon-http) (require 'mastodon-toot) (require 'url) +(require 'thingatpt) +(require 'shr) (declare-function discover-add-context-menu "discover") (declare-function emojify-mode "emojify") @@ -279,7 +281,7 @@ If a status or account is found, load it in `mastodon.el', if not, just browse the URL in the normal fashion." (interactive) (let* ((query (or query-url - (url-get-url-at-point) + (thing-at-point-url-at-point) (get-text-property (point) 'shr-url) (read-string "Lookup URL: ")))) (if (not (mastodon--masto-url-p query)) -- cgit v1.2.3 From 10c5926d75a67ab799e63f896546f54e3706d65d Mon Sep 17 00:00:00 2001 From: marty hiatt Date: Sat, 5 Nov 2022 13:39:31 +0100 Subject: use ts library to format poll expiry --- Cask | 1 + lisp/mastodon-tl.el | 22 ++++++++++++---------- lisp/mastodon.el | 2 +- 3 files changed, 14 insertions(+), 11 deletions(-) (limited to 'lisp/mastodon.el') diff --git a/Cask b/Cask index a960f81..c193326 100644 --- a/Cask +++ b/Cask @@ -7,6 +7,7 @@ (depends-on "request" "0.3.0") (depends-on "seq") (depends-on "persist") +(depends-on "ts") (development (depends-on "ert-runner") diff --git a/lisp/mastodon-tl.el b/lisp/mastodon-tl.el index 2db5700..6f53f93 100644 --- a/lisp/mastodon-tl.el +++ b/lisp/mastodon-tl.el @@ -5,7 +5,7 @@ ;; Marty Hiatt ;; Maintainer: Marty Hiatt ;; Version: 1.0.0 -;; Package-Requires: ((emacs "27.1")) +;; Package-Requires: ((emacs "27.1") (ts "0.3")) ;; Homepage: https://codeberg.org/martianh/mastodon.el ;; This file is not part of GNU Emacs. @@ -32,6 +32,7 @@ ;;; Code: (require 'shr) +(require 'ts) (require 'thingatpt) ; for word-at-point (require 'time-date) (require 'cl-lib) @@ -982,19 +983,20 @@ this just means displaying toot client." 'face 'font-lock-comment-face) (let ((str (if expired-p "Poll expired." - (matodon-tl--format-poll-expiry expiry)))) + (mastodon-tl--format-poll-expiry expiry)))) (propertize str 'face 'font-lock-comment-face)) "\n"))) -(defun matodon-tl--format-poll-expiry (timestamp) +(defun mastodon-tl--format-poll-expiry (timestamp) "Convert poll expiry TIMESTAMP into a descriptive string." - (let ((parsed (iso8601-parse timestamp))) - (cond ((> (decoded-time-day parsed) 0) - (format "%s days left" (decoded-time-day parsed))) - ((> (decoded-time-hour parsed) 0) - (format "%s hours left" (decoded-time-hour parsed))) - ((> (decoded-time-minute parsed) 0) - (format "%s minutes left" (decoded-time-minute parsed)))))) + (let ((parsed (ts-human-duration + (ts-diff (ts-parse timestamp) (ts-now))))) + (cond ((> (plist-get parsed :days) 0) + (format "%s days, %s hours left" (plist-get parsed :days) (plist-get parsed :hours))) + ((> (plist-get parsed :hours) 0) + (format "%s hours, %s minutes left" (plist-get parsed :hours) (plist-get parsed :minutes))) + ((> (plist-get parsed :minutes) 0) + (format "%s minutes left" (plist-get parsed :minutes)))))) (defun mastodon-tl--poll-vote (option) "If there is a poll at point, prompt user for OPTION to vote on it." diff --git a/lisp/mastodon.el b/lisp/mastodon.el index a5ba9e4..5ec48b6 100644 --- a/lisp/mastodon.el +++ b/lisp/mastodon.el @@ -5,7 +5,7 @@ ;; Author: Johnson Denen ;; Maintainer: Marty Hiatt ;; Version: 1.0.0 -;; Package-Requires: ((emacs "27.1") (request "0.3.0") (persist "0.4")) +;; Package-Requires: ((emacs "27.1") (request "0.3.0") (persist "0.4") (ts "0.3")) ;; Homepage: https://codeberg.org/martianh/mastodon.el ;; This file is not part of GNU Emacs. -- cgit v1.2.3 From 32679d73fdad010718be972ce29d5b63b91ef8c5 Mon Sep 17 00:00:00 2001 From: marty hiatt Date: Sat, 5 Nov 2022 16:47:40 +0100 Subject: edit header prop line for melpa --- lisp/mastodon.el | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lisp/mastodon.el') diff --git a/lisp/mastodon.el b/lisp/mastodon.el index 5ec48b6..4085c86 100644 --- a/lisp/mastodon.el +++ b/lisp/mastodon.el @@ -1,4 +1,4 @@ -;;; mastodon.el --- Client for Mastodon -*- lexical-binding: t -*- +;;; mastodon.el --- Client for Mastodon, a federated social network -*- lexical-binding: t -*- ;; Copyright (C) 2017-2019 Johnson Denen ;; Copyright (C) 2021 Abhiseck Paira -- cgit v1.2.3 From 8f5cb76677836703f0b554fe5ab669ba1e9d6d91 Mon Sep 17 00:00:00 2001 From: marty hiatt Date: Sat, 5 Nov 2022 17:03:17 +0100 Subject: boilerplate --- lisp/mastodon.el | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'lisp/mastodon.el') diff --git a/lisp/mastodon.el b/lisp/mastodon.el index 4085c86..3b0a7d0 100644 --- a/lisp/mastodon.el +++ b/lisp/mastodon.el @@ -1,8 +1,10 @@ ;;; mastodon.el --- Client for Mastodon, a federated social network -*- lexical-binding: t -*- ;; Copyright (C) 2017-2019 Johnson Denen +;; Copyright (C) 2020-2022 Marty Hiatt ;; Copyright (C) 2021 Abhiseck Paira ;; Author: Johnson Denen +;; Marty Hiatt ;; Maintainer: Marty Hiatt ;; Version: 1.0.0 ;; Package-Requires: ((emacs "27.1") (request "0.3.0") (persist "0.4") (ts "0.3")) @@ -29,7 +31,7 @@ ;; mastodon.el is an Emacs client for Mastodon , ;; the federated microblogging social network. It also works with Pleroma instances. -;; see the readme file at https://codeberg.org/martianh/mastodon.el for set up and usage details. +;; See the readme file at https://codeberg.org/martianh/mastodon.el for set up and usage details. ;;; Code: (require 'cl-lib) ; for `cl-some' call in mastodon -- cgit v1.2.3