* bug#37489: 27.0.50; Make `debbugs-gnu-search' work with `repeat-complex-command'
@ 2019-09-23 6:26 Michael Heerdegen
2019-09-23 13:26 ` Michael Albinus
0 siblings, 1 reply; 4+ messages in thread
From: Michael Heerdegen @ 2019-09-23 6:26 UTC (permalink / raw)
To: 37489
Hi,
when I want to repeat searching bugs with `debbugs-gnu-search' and a
similar query, I currently have to specify everything again.
`repeat-complex-command' is no help since the command currently has no
arguments. Could we please make it work with `repeat-complex-command'?
The argument list of `debbugs-gnu-search' (currently empty) needs to
contain all information gathered, that seems to be the value of
`debbugs-gnu-current-query' and all arguments of the `debbugs-gnu' call.
Then most of the current function body should be moved into the
interactive form. In the body only `debbugs-gnu-current-query' should
be let-bound to the first part of the function arguments, and
`debbugs-gnu' should be called with the rest.
TIA,
Michael.
^ permalink raw reply [flat|nested] 4+ messages in thread
* bug#37489: 27.0.50; Make `debbugs-gnu-search' work with `repeat-complex-command'
2019-09-23 6:26 bug#37489: 27.0.50; Make `debbugs-gnu-search' work with `repeat-complex-command' Michael Heerdegen
@ 2019-09-23 13:26 ` Michael Albinus
2019-09-24 3:00 ` Michael Heerdegen
0 siblings, 1 reply; 4+ messages in thread
From: Michael Albinus @ 2019-09-23 13:26 UTC (permalink / raw)
To: Michael Heerdegen; +Cc: 37489
[-- Attachment #1: Type: text/plain, Size: 1547 bytes --]
Michael Heerdegen <michael_heerdegen@web.de> writes:
> Hi,
Hi Michael,
> when I want to repeat searching bugs with `debbugs-gnu-search' and a
> similar query, I currently have to specify everything again.
> `repeat-complex-command' is no help since the command currently has no
> arguments. Could we please make it work with `repeat-complex-command'?
>
> The argument list of `debbugs-gnu-search' (currently empty) needs to
> contain all information gathered, that seems to be the value of
> `debbugs-gnu-current-query' and all arguments of the `debbugs-gnu' call.
>
> Then most of the current function body should be moved into the
> interactive form. In the body only `debbugs-gnu-current-query' should
> be let-bound to the first part of the function arguments, and
> `debbugs-gnu' should be called with the rest.
The appended patch shall do the job, you might test. However, I fear we
will open a Pandora's box. We must set both debbugs-gnu-current-query
and debbugs-gnu-current-filter, it depends on whether PHRASE is a
string, or not. And even the allowed arguments in both cases are
different. So it is very easy to make it wrong when editing the argument
list. Even *I* would need to consult the implementation, in order to
know what's allowed, and what's not. That's why the arguments were
collected interactively only, so far.
Anyway, I'm interested in your feedback whether that's the way to go. If
yes, I would add some further sanity checks for QUERY, before callings
debbugs-gnu.
> TIA,
>
> Michael.
Best regards, Michael.
[-- Attachment #2: Type: text/plain, Size: 11426 bytes --]
diff --git a/packages/debbugs/debbugs-gnu.el b/packages/debbugs/debbugs-gnu.el
index 82dd582dc..f70becc27 100644
--- a/packages/debbugs/debbugs-gnu.el
+++ b/packages/debbugs/debbugs-gnu.el
@@ -417,172 +417,174 @@ be empty, in this case only the following attributes are used for
search."))
;;;###autoload
-(defun debbugs-gnu-search ()
+(defun debbugs-gnu-search (phrase query severities packages archivedp)
"Search for Emacs bugs interactively.
Search arguments are requested interactively. The \"search
phrase\" is used for full text search in the bugs database.
Further key-value pairs are requested until an empty key is
returned. If a key cannot be queried by a SOAP request, it is
-marked as \"client-side filter\"."
- (interactive)
+marked as \"client-side filter\".
- (unwind-protect
- (let ((date-format
- (eval-when-compile
- (concat"\\([[:digit:]]\\{4\\}\\)-"
- "\\([[:digit:]]\\{1,2\\}\\)-"
- "\\([[:digit:]]\\{1,2\\}\\)")))
- key val1 val2 phrase severities packages archivedp)
-
- ;; Check for the phrase.
- (setq phrase (read-string debbugs-gnu-phrase-prompt))
- (if (zerop (length phrase))
- (setq phrase nil)
- (add-to-list 'debbugs-gnu-current-query (cons 'phrase phrase)))
- ;; We suppress closed bugs if there is no phrase.
- (setq debbugs-gnu-current-suppress
- (if (not debbugs-gnu-suppress-closed)
- nil
- (null phrase)))
-
- ;; The other queries.
- (catch :finished
- (while t
- (setq key (completing-read
- "Enter attribute: "
- (if phrase
- (append
- '("severity" "package" "tags"
- "author" "date" "subject")
- ;; Client-side filters.
- (mapcar
- (lambda (key)
- (propertize
- key 'face 'debbugs-gnu-done
- 'help-echo "Client-side filter"))
- '("status")))
- (append
- '("severity" "package" "archive" "src" "status" "tag"
- "owner" "submitter" "maint" "correspondent")
- ;; Client-side filters.
- (mapcar
- (lambda (key)
- (propertize
- key 'face 'debbugs-gnu-done
- 'help-echo "Client-side filter"))
- '("date" "log_modified" "last_modified"
- "found_date" "fixed_date" "unarchived"
- "subject" "done" "forwarded" "msgid" "summary"))))
- nil t))
- (cond
- ;; Server-side queries.
- ((equal key "severity")
- (setq
- severities
- (completing-read-multiple
- "Enter severities: " debbugs-gnu-all-severities nil t
- (mapconcat #'identity debbugs-gnu-default-severities ","))))
-
- ((equal key "package")
- (setq
- packages
- (completing-read-multiple
- "Enter packages: " debbugs-gnu-all-packages nil t
- (mapconcat #'identity debbugs-gnu-default-packages ","))))
-
- ((equal key "archive")
- ;; We simplify, by assuming just archived bugs are requested.
- (setq archivedp t))
-
- ((member key '("src" "tag" "tags"))
- (setq val1 (read-string (format "Enter %s: " key)))
- (when (not (zerop (length val1)))
- (add-to-list
- 'debbugs-gnu-current-query (cons (intern key) val1))))
-
- ((member
- key '("author" "owner" "submitter" "maint" "correspondent"))
- (setq val1 (read-string "Enter email address: "))
- (when (not (zerop (length val1)))
- (add-to-list
- 'debbugs-gnu-current-query
- (cons (intern (if (equal key "author") "@author" key)) val1))))
-
- ;; Client-side filters.
- ((equal key "status")
- (setq
- val1
- (completing-read
- (format "Enter status%s: "
- (if (null phrase) "" " (client-side filter)"))
- '("open" "forwarded" "done") nil t))
- (when (not (zerop (length val1)))
- (if (null phrase)
- (add-to-list
- 'debbugs-gnu-current-query (cons (intern key) val1))
- (add-to-list
- 'debbugs-gnu-current-filter (cons 'pending val1)))))
-
- ((member key '("date" "log_modified" "last_modified"
- "found_date" "fixed_date" "unarchived"))
- (setq val1
- (debbugs-gnu-calendar-read
- (format "Enter %s before YYYY-MM-DD%s: "
- key (if phrase "" " (client-side filter)"))
- (lambda (x)
- (string-match (concat "^\\(" date-format "\\|\\)$") x))))
- (if (string-match date-format val1)
- (setq val1 (floor
- (float-time
- (encode-time
- 0 0 0
- (string-to-number (match-string 3 val1))
- (string-to-number (match-string 2 val1))
- (string-to-number (match-string 1 val1))))))
- (setq val1 nil))
- (setq val2
- (debbugs-gnu-calendar-read
- (format "Enter %s after YYYY-MM-DD%s: "
- key (if phrase "" " (client-side filter)"))
- (lambda (x)
- (string-match (concat "^\\(" date-format "\\|\\)$") x))))
- (if (string-match date-format val2)
- (setq val2 (floor
- (float-time
- (encode-time
- 0 0 0
- (string-to-number (match-string 3 val2))
- (string-to-number (match-string 2 val2))
- (string-to-number (match-string 1 val2))))))
- (setq val2 nil))
- (when (or val1 val2)
- (add-to-list
- (if phrase
- 'debbugs-gnu-current-query 'debbugs-gnu-current-filter)
- (cons (intern
- (if (and phrase (equal key "date")) "@cdate" key))
- (cons val1 val2)))))
-
- ;; "subject", "done", "forwarded", "msgid", "summary".
- ((not (zerop (length key)))
- (setq val1
- (funcall
- (if phrase 'read-string 'read-regexp)
- (format "Enter %s%s: "
- key (if phrase "" " (client-side filter)"))))
- (when (not (zerop (length val1)))
- (add-to-list
- (if phrase
- 'debbugs-gnu-current-query 'debbugs-gnu-current-filter)
- (cons (intern key) val1))))
-
- ;; The End.
- (t (throw :finished nil)))))
-
- ;; Do the search.
- (debbugs-gnu severities packages archivedp)
- (when (called-interactively-p 'interactive)
- (message "Search finished")))))
+When using interactively, use \\[repeat-complex-command] after
+this command for reusing the argument list. Be careful in
+editing the arguments, because the allowed attributes for QUERY
+depend on PHRASE being a string, or nil."
+ (interactive
+ (let ((date-format
+ (eval-when-compile
+ (concat"\\([[:digit:]]\\{4\\}\\)-"
+ "\\([[:digit:]]\\{1,2\\}\\)-"
+ "\\([[:digit:]]\\{1,2\\}\\)")))
+ key val1 val2 phrase query severities packages archivedp)
+
+ ;; Check for the phrase.
+ (setq phrase (read-string debbugs-gnu-phrase-prompt))
+ (when (zerop (length phrase))
+ (setq phrase nil))
+
+ ;; The other queries.
+ (catch :finished
+ (while t
+ (setq key (completing-read
+ "Enter attribute: "
+ (if phrase
+ (append
+ '("severity" "package" "tags"
+ "author" "date" "subject")
+ ;; Client-side filters.
+ (mapcar
+ (lambda (key)
+ (propertize
+ key 'face 'debbugs-gnu-done
+ 'help-echo "Client-side filter"))
+ '("status")))
+ (append
+ '("severity" "package" "archive" "src" "status" "tag"
+ "owner" "submitter" "maint" "correspondent")
+ ;; Client-side filters.
+ (mapcar
+ (lambda (key)
+ (propertize
+ key 'face 'debbugs-gnu-done
+ 'help-echo "Client-side filter"))
+ '("date" "log_modified" "last_modified"
+ "found_date" "fixed_date" "unarchived"
+ "subject" "done" "forwarded" "msgid" "summary"))))
+ nil t))
+ (cond
+ ;; Server-side queries.
+ ((equal key "severity")
+ (setq
+ severities
+ (completing-read-multiple
+ "Enter severities: " debbugs-gnu-all-severities nil t
+ (mapconcat #'identity debbugs-gnu-default-severities ","))))
+
+ ((equal key "package")
+ (setq
+ packages
+ (completing-read-multiple
+ "Enter packages: " debbugs-gnu-all-packages nil t
+ (mapconcat #'identity debbugs-gnu-default-packages ","))))
+
+ ((equal key "archive")
+ ;; We simplify, by assuming just archived bugs are requested.
+ (setq archivedp t))
+
+ ((member key '("src" "tag" "tags"))
+ (setq val1 (read-string (format "Enter %s: " key)))
+ (when (not (zerop (length val1)))
+ (push (cons (intern key) val1) query)))
+
+ ((member
+ key '("author" "owner" "submitter" "maint" "correspondent"))
+ (setq val1 (read-string "Enter email address: "))
+ (when (not (zerop (length val1)))
+ (push
+ (cons (intern (if (equal key "author") "@author" key)) val1)
+ query)))
+
+ ;; Client-side filters.
+ ((equal key "status")
+ (setq
+ val1
+ (completing-read
+ (format "Enter status%s: "
+ (if (null phrase) "" " (client-side filter)"))
+ '("open" "forwarded" "done") nil t))
+ (when (not (zerop (length val1)))
+ (push (cons (if (null phrase) (intern key) 'pending) val1) query)))
+
+ ((member key '("date" "log_modified" "last_modified"
+ "found_date" "fixed_date" "unarchived"))
+ (setq val1
+ (debbugs-gnu-calendar-read
+ (format "Enter %s before YYYY-MM-DD%s: "
+ key (if phrase "" " (client-side filter)"))
+ (lambda (x)
+ (string-match (concat "^\\(" date-format "\\|\\)$") x))))
+ (if (string-match date-format val1)
+ (setq val1 (floor
+ (float-time
+ (encode-time
+ 0 0 0
+ (string-to-number (match-string 3 val1))
+ (string-to-number (match-string 2 val1))
+ (string-to-number (match-string 1 val1))))))
+ (setq val1 nil))
+ (setq val2
+ (debbugs-gnu-calendar-read
+ (format "Enter %s after YYYY-MM-DD%s: "
+ key (if phrase "" " (client-side filter)"))
+ (lambda (x)
+ (string-match (concat "^\\(" date-format "\\|\\)$") x))))
+ (if (string-match date-format val2)
+ (setq val2 (floor
+ (float-time
+ (encode-time
+ 0 0 0
+ (string-to-number (match-string 3 val2))
+ (string-to-number (match-string 2 val2))
+ (string-to-number (match-string 1 val2))))))
+ (setq val2 nil))
+ (when (or val1 val2)
+ (push
+ (cons (intern (if (and phrase (equal key "date")) "@cdate" key))
+ (cons val1 val2))
+ query)))
+
+ ;; "subject", "done", "forwarded", "msgid", "summary".
+ ((not (zerop (length key)))
+ (setq val1
+ (funcall
+ (if phrase 'read-string 'read-regexp)
+ (format "Enter %s%s: "
+ key (if phrase "" " (client-side filter)"))))
+ (when (not (zerop (length val1)))
+ (push (cons (intern key) val1) query)))
+
+ ;; The End.
+ (t (throw :finished nil)))))
+
+ ;; The arguments.
+ (list phrase query severities packages archivedp)))
+
+
+ ;; We suppress closed bugs if there is no phrase.
+ (setq debbugs-gnu-current-suppress
+ (if (not debbugs-gnu-suppress-closed)
+ nil
+ (null phrase)))
+
+ ;; Set phrase and query.
+ (if phrase
+ (setq debbugs-gnu-current-query
+ (append (list (cons 'phrase phrase)) query))
+ (setq debbugs-gnu-current-filter query))
+
+ ;; Do the search.
+ (debbugs-gnu severities packages archivedp)
+ (message "Search finished"))
;;;###autoload
(defun debbugs-gnu-patches ()
^ permalink raw reply related [flat|nested] 4+ messages in thread
* bug#37489: 27.0.50; Make `debbugs-gnu-search' work with `repeat-complex-command'
2019-09-23 13:26 ` Michael Albinus
@ 2019-09-24 3:00 ` Michael Heerdegen
2019-09-24 6:51 ` Michael Albinus
0 siblings, 1 reply; 4+ messages in thread
From: Michael Heerdegen @ 2019-09-24 3:00 UTC (permalink / raw)
To: Michael Albinus; +Cc: 37489
Michael Albinus <michael.albinus@gmx.de> writes:
> The appended patch shall do the job, you might test.
Seems to work fine, yes, thanks.
> However, I fear we will open a Pandora's box. We must set both
> debbugs-gnu-current-query and debbugs-gnu-current-filter, it depends
> on whether PHRASE is a string, or not. And even the allowed arguments
> in both cases are different. So it is very easy to make it wrong when
> editing the argument list. Even *I* would need to consult the
> implementation, in order to know what's allowed, and what's
> not.
I don't find it this problematic. It's ok when not all combinations of
arguments are allowed. But instead of consulting the implementation, it
would of course be better to describe limitations in the docstring. If
it gets too complicated, maybe the list of arguments could be changed to
reflect the implementation even more.
Anyway, the patch is all that I wanted. If the command barks the last
resort is to go through the queries again, which I have to do now
anyway.
> I would add some further sanity checks for QUERY, before callings
> debbugs-gnu.
That might be appropriate, but adding some details to the docstring in
addition along the way might not be wrong, too. You don't even need to
explain each argument in detail (maybe you could even point to other
functions' docstring for that?), just enough to let me know what would
not work. FWIW, I never called the command with an empty phrase, since
I didn't know that this is allowed and even then I would rather expect
that the server would blacklist me :-)
Regards,
Michael.
^ permalink raw reply [flat|nested] 4+ messages in thread
* bug#37489: 27.0.50; Make `debbugs-gnu-search' work with `repeat-complex-command'
2019-09-24 3:00 ` Michael Heerdegen
@ 2019-09-24 6:51 ` Michael Albinus
0 siblings, 0 replies; 4+ messages in thread
From: Michael Albinus @ 2019-09-24 6:51 UTC (permalink / raw)
To: Michael Heerdegen; +Cc: 37489-done
Michael Heerdegen <michael_heerdegen@web.de> writes:
Hi Michael,
>> The appended patch shall do the job, you might test.
>
> Seems to work fine, yes, thanks.
Thanks for testing. There was still an error in the patch; it didn't
distinguish between queries and filters. I have fixed this.
>> However, I fear we will open a Pandora's box. We must set both
>> debbugs-gnu-current-query and debbugs-gnu-current-filter, it depends
>> on whether PHRASE is a string, or not. And even the allowed arguments
>> in both cases are different. So it is very easy to make it wrong when
>> editing the argument list. Even *I* would need to consult the
>> implementation, in order to know what's allowed, and what's
>> not.
>
> I don't find it this problematic. It's ok when not all combinations of
> arguments are allowed. But instead of consulting the implementation, it
> would of course be better to describe limitations in the docstring. If
> it gets too complicated, maybe the list of arguments could be changed to
> reflect the implementation even more.
It's even more complex. There is the difference whether an argument is
appropriate or not, depending on QUERY being a string or nil. But there
is also the difference whether an argument is sent to the server, or
whether the argument's discrimination is done client-side. The latter is
much less performant.
> Anyway, the patch is all that I wanted. If the command barks the last
> resort is to go through the queries again, which I have to do now
> anyway.
>
>> I would add some further sanity checks for QUERY, before callings
>> debbugs-gnu.
>
> That might be appropriate, but adding some details to the docstring in
> addition along the way might not be wrong, too. You don't even need to
> explain each argument in detail (maybe you could even point to other
> functions' docstring for that?), just enough to let me know what would
> not work. FWIW, I never called the command with an empty phrase, since
> I didn't know that this is allowed and even then I would rather expect
> that the server would blacklist me :-)
See the manual, it tells you :-)
`debugs-gnu search' is designed to handle all of this interactively. Now,
that we have arguments, and this command can be called like a function,
I've added a reference to the docstring, pointing to the manual. Plus
the promised sanity checks.
I've pushed the changes to GNU ELPA. I've also released debbugs 0.20,
because the solution for bug#36903, which was blocking the release, is
expected to be applied in gnus.
> Regards,
>
> Michael.
Best regards, Michael.
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2019-09-24 6:51 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-09-23 6:26 bug#37489: 27.0.50; Make `debbugs-gnu-search' work with `repeat-complex-command' Michael Heerdegen
2019-09-23 13:26 ` Michael Albinus
2019-09-24 3:00 ` Michael Heerdegen
2019-09-24 6:51 ` Michael Albinus
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).