From 5a47a076600d108d6820d563b76e246b3cfa210c Mon Sep 17 00:00:00 2001 From: dickmao Date: Mon, 30 Sep 2019 17:10:56 -0400 Subject: [PATCH 1/2] package-lint under emacs27 --- nnhackernews.el | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/nnhackernews.el b/nnhackernews.el index 54688cd..02910eb 100644 --- a/nnhackernews.el +++ b/nnhackernews.el @@ -6,7 +6,7 @@ ;; Version: 0.1.0 ;; Keywords: news ;; URL: https://github.com/dickmao/nnhackernews -;; Package-Requires: ((emacs "25") (request "20190819") (dash "20190401") (dash-functional "20180107") (anaphora "20180618")) +;; Package-Requires: ((emacs "25.1") (request "20190819") (dash "20190401") (dash-functional "20180107") (anaphora "20180618")) ;; This file is NOT part of GNU Emacs. @@ -319,8 +319,9 @@ If NOQUERY, return nil and avoid querying if not extant." (error "nnhackernews--domify: need libxml-parse-html-region")))) (cl-defun nnhackernews--request-login-success (&key data &allow-other-keys) - "After some time, logging in via browser recaptcha might be necessary. + "Validate login depending on what DATA say. +After some time, logging in via browser recaptcha might be necessary. Remember `string-match-p' is always case-insensitive as is all elisp pattern matching." (when (and (stringp data) (string-match-p (regexp-quote "validation required") data)) @@ -369,7 +370,7 @@ Remember `string-match-p' is always case-insensitive as is all elisp pattern mat ,dom)) (cl-defun nnhackernews--request-hidden-success (&key data response &allow-other-keys) - "If necessary, login first, then return plist of :fnid and :fnop." + "Based on DATA and RESPONSE, we may need to login first. Return :fnid and :fnop." (let* ((dom (nnhackernews--domify data)) (form (car (alist-get 'form (alist-get 'body dom)))) (url (request-response-url response)) @@ -735,7 +736,9 @@ The two hashtables being reconciled are `nnhackernews-location-hashtb' and (cl-defun nnhackernews--request (caller url &rest attributes &key parser (backend 'url-retrieve) &allow-other-keys) - "Prefix errors with CALLER when executing synchronous request to URL." + "Prefix errors with CALLER executing synchronous request to URL. + +Request shall contain ATTRIBUTES, one of which is PARSER of the response, if provided (shall default to verbatim dump of response, if not). BACKEND can be curl (defaults to `url-retrieve')." (unless parser (setq attributes (append attributes (list :parser #'buffer-string)))) (setq attributes @@ -749,7 +752,7 @@ The two hashtables being reconciled are `nnhackernews-location-hashtb' and attributes))) (cl-defun nnhackernews--request-vote-success (item vote &key data &allow-other-keys) - "If necessary, login first, then locate vote link depending on VOTE sign." + "If necessary, login first, then locate ITEM VOTE link in DATA (will depend on VOTE sign)." (let* ((dom (nnhackernews--domify data)) (before (format "%s_%s" (if (> vote 0) "up" "un") item)) (after (format "%s_%s" (if (<= vote 0) "up" "un") item)) @@ -859,7 +862,9 @@ The two hashtables being reconciled are `nnhackernews-location-hashtb' and &allow-other-keys &aux (response-status (request-response-status-code response))) - "Refer to CALLER when reporting a submit error." + "Refer to CALLER when reporting a submit error. + +Also report http code of RESPONSE, which is distinct from SYMBOL-STATUS, and ERROR-THROWN. The http code is stored in RESPONSE-STATUS." (gnus-message 3 "%s %s: http status %s, %s" caller symbol-status response-status (error-message-string error-thrown))) @@ -867,7 +872,8 @@ The two hashtables being reconciled are `nnhackernews-location-hashtb' and (caller posturl postdata retry &key data response &allow-other-keys) "If necessary, login, then \"goto\" fields take us to target. -And if accused of being a bot, retry with CALLER, POSTURL, POSTDATA (and toggle RETRY)." +And if accused of being a bot, retry with CALLER, POSTURL, POSTDATA +\(and toggle RETRY). Use DATA and RESPONSE to determine if we need to login again." (let* ((dom (nnhackernews--domify data)) (form (car (alist-get 'form (alist-get 'body dom)))) (url (request-response-url response)) @@ -1174,7 +1180,7 @@ Optionally provide STATIC-MAX-ITEM and STATIC-NEWSTORIES to prevent querying out (message "%s: %s" server (substring string (length magic)))))) (cl-defun nnhackernews--request-delete-success (&key data &allow-other-keys) - "Delete with extreme prejudice." + "Delete with extreme prejudice the hidden items in DATA." (let* ((dom (nnhackernews--domify data)) hidden) (nnhackernews--extract-hidden dom hidden) -- 2.34.1 From 76517b9e1801dfbbe7f49316b6f1d53c571db350 Mon Sep 17 00:00:00 2001 From: dickmao Date: Mon, 30 Sep 2019 19:40:54 -0400 Subject: [PATCH 2/2] C-c C-c send no longer goes to summary buffer? --- features/rpc.feature | 1 - nnhackernews.el | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/features/rpc.feature b/features/rpc.feature index baf84c7..3e74066 100644 --- a/features/rpc.feature +++ b/features/rpc.feature @@ -89,6 +89,5 @@ Scenario: submit a text which must be titled And I type "this is a test" And I dump buffer And I press "C-c C-c" - Then I should be in buffer "*Summary nnhackernews:news*" When I switch to buffer "*Messages*" Then I should not see "Couldn't send message via news" diff --git a/nnhackernews.el b/nnhackernews.el index 02910eb..b5d8b1a 100644 --- a/nnhackernews.el +++ b/nnhackernews.el @@ -578,7 +578,7 @@ FORCE is generally t unless coming from `nnhackernews--score-pending'." nnhackernews-score-files)))) (let* ((num-headers (length (nnhackernews-get-headers (gnus-group-real-name group)))) - (marks (gnus-info-marks (nth 2 (gnus-group-entry group)))) + (marks (gnus-info-marks (gnus-get-info group))) (seen (or (cdr (--max-by (> (or (cdr it) 0) (or (cdr other) 0)) (alist-get 'seen marks))) 0))) -- 2.34.1