diff options
| author | Po Lu | 2023-06-13 16:20:58 +0800 |
|---|---|---|
| committer | Po Lu | 2023-06-13 16:20:58 +0800 |
| commit | 5268f8476fc3e1bb2ead05a75390dbe9ef852d09 (patch) | |
| tree | 4a05a851df1fe7fbfa4e5dc9ca6b10665a692b12 | |
| parent | 32c627a5ac314ff0ca97ac99d2357f84565f2581 (diff) | |
| download | emacs-5268f8476fc3e1bb2ead05a75390dbe9ef852d09.tar.gz emacs-5268f8476fc3e1bb2ead05a75390dbe9ef852d09.zip | |
Improve behavior of Gnus on Android
* etc/NEWS: Fix typo.
* lisp/gnus/gnus-score.el (gnus-read-char): New function.
(gnus-summary-increase-score): Use it to display a dialog box on
Android, where input methods have trouble with plain old
read-char.
| -rw-r--r-- | etc/NEWS | 1 | ||||
| -rw-r--r-- | lisp/gnus/gnus-score.el | 70 |
2 files changed, 54 insertions, 17 deletions
| @@ -102,7 +102,6 @@ plus, minus, check-mark, start, etc. | |||
| 102 | Many touch screen gestures are now implemented, as is support for | 102 | Many touch screen gestures are now implemented, as is support for |
| 103 | tapping buttons and opening menus. | 103 | tapping buttons and opening menus. |
| 104 | 104 | ||
| 105 | |||
| 106 | --- | 105 | --- |
| 107 | ** On X, Emacs now supports input methods which perform "string conversion". | 106 | ** On X, Emacs now supports input methods which perform "string conversion". |
| 108 | This means an input method can now ask Emacs to delete text | 107 | This means an input method can now ask Emacs to delete text |
diff --git a/lisp/gnus/gnus-score.el b/lisp/gnus/gnus-score.el index 05459ffae88..8bdfccf7eb8 100644 --- a/lisp/gnus/gnus-score.el +++ b/lisp/gnus/gnus-score.el | |||
| @@ -517,6 +517,35 @@ of the last successful match.") | |||
| 517 | "t" #'gnus-score-find-trace | 517 | "t" #'gnus-score-find-trace |
| 518 | "w" #'gnus-score-find-favorite-words)) | 518 | "w" #'gnus-score-find-favorite-words)) |
| 519 | 519 | ||
| 520 | |||
| 521 | |||
| 522 | ;; Touch screen ``character reading'' routines for | ||
| 523 | ;; `gnus-summary-increase-score' and friends. | ||
| 524 | |||
| 525 | (defun gnus-read-char (prompt options) | ||
| 526 | "Read a character from the keyboard. | ||
| 527 | |||
| 528 | On Android, if `use-dialog-box-p' returns non-nil, display a | ||
| 529 | dialog box containing PROMPT, with buttons representing each of | ||
| 530 | item in the list of characters OPTIONS instead. | ||
| 531 | |||
| 532 | Value is the character read, as with `read-char', or nil upon | ||
| 533 | failure." | ||
| 534 | (if (and (display-graphic-p) (featurep 'android) | ||
| 535 | (use-dialog-box-p)) | ||
| 536 | ;; Set up the dialog box. | ||
| 537 | (let ((dialog (cons prompt ; Message displayed in dialog box. | ||
| 538 | (mapcar (lambda (arg) | ||
| 539 | (cons (char-to-string arg) | ||
| 540 | arg)) | ||
| 541 | options)))) | ||
| 542 | ;; Display the dialog box. | ||
| 543 | (x-popup-dialog t dialog)) | ||
| 544 | ;; Fall back to read-char. | ||
| 545 | (read-char))) | ||
| 546 | |||
| 547 | |||
| 548 | |||
| 520 | ;; Summary score file commands | 549 | ;; Summary score file commands |
| 521 | 550 | ||
| 522 | ;; Much modification of the kill (ahem, score) code and lots of the | 551 | ;; Much modification of the kill (ahem, score) code and lots of the |
| @@ -588,21 +617,23 @@ current score file." | |||
| 588 | (aref (symbol-name gnus-score-default-type) 0))) | 617 | (aref (symbol-name gnus-score-default-type) 0))) |
| 589 | (pchar (and gnus-score-default-duration | 618 | (pchar (and gnus-score-default-duration |
| 590 | (aref (symbol-name gnus-score-default-duration) 0))) | 619 | (aref (symbol-name gnus-score-default-duration) 0))) |
| 591 | entry temporary type match extra) | 620 | entry temporary type match extra header-string) |
| 592 | 621 | ||
| 593 | (unwind-protect | 622 | (unwind-protect |
| 594 | (progn | 623 | (progn |
| 595 | 624 | (setq header-string | |
| 625 | (format "%s header (%s?): " (if increase "Increase" "Lower") | ||
| 626 | (mapconcat (lambda (s) (char-to-string (car s))) | ||
| 627 | char-to-header ""))) | ||
| 596 | ;; First we read the header to score. | 628 | ;; First we read the header to score. |
| 597 | (while (not hchar) | 629 | (while (not hchar) |
| 598 | (if mimic | 630 | (if mimic |
| 599 | (progn | 631 | (progn |
| 600 | (sit-for 1) | 632 | (sit-for 1) |
| 601 | (message "%c-" prefix)) | 633 | (message "%c-" prefix)) |
| 602 | (message "%s header (%s?): " (if increase "Increase" "Lower") | 634 | (message header-string)) |
| 603 | (mapconcat (lambda (s) (char-to-string (car s))) | 635 | (setq hchar (gnus-read-char header-string |
| 604 | char-to-header ""))) | 636 | (mapcar #'car char-to-header))) |
| 605 | (setq hchar (read-char)) | ||
| 606 | (when (or (= hchar ??) (= hchar ?\C-h)) | 637 | (when (or (= hchar ??) (= hchar ?\C-h)) |
| 607 | (setq hchar nil) | 638 | (setq hchar nil) |
| 608 | (gnus-score-insert-help "Match on header" char-to-header 1))) | 639 | (gnus-score-insert-help "Match on header" char-to-header 1))) |
| @@ -625,17 +656,20 @@ current score file." | |||
| 625 | (nth 3 s)) | 656 | (nth 3 s)) |
| 626 | s nil)) | 657 | s nil)) |
| 627 | char-to-type)))) | 658 | char-to-type)))) |
| 659 | (setq header-string | ||
| 660 | (format "%s header `%s' with match type (%s?): " | ||
| 661 | (if increase "Increase" "Lower") | ||
| 662 | (nth 1 entry) | ||
| 663 | (mapconcat (lambda (s) (char-to-string (car s))) | ||
| 664 | legal-types ""))) | ||
| 628 | ;; We continue reading - the type. | 665 | ;; We continue reading - the type. |
| 629 | (while (not tchar) | 666 | (while (not tchar) |
| 630 | (if mimic | 667 | (if mimic |
| 631 | (progn | 668 | (progn |
| 632 | (sit-for 1) (message "%c %c-" prefix hchar)) | 669 | (sit-for 1) (message "%c %c-" prefix hchar)) |
| 633 | (message "%s header `%s' with match type (%s?): " | 670 | (message header-string)) |
| 634 | (if increase "Increase" "Lower") | 671 | (setq tchar (gnus-read-char header-string |
| 635 | (nth 1 entry) | 672 | (mapcar #'car legal-types))) |
| 636 | (mapconcat (lambda (s) (char-to-string (car s))) | ||
| 637 | legal-types ""))) | ||
| 638 | (setq tchar (read-char)) | ||
| 639 | (when (or (= tchar ??) (= tchar ?\C-h)) | 673 | (when (or (= tchar ??) (= tchar ?\C-h)) |
| 640 | (setq tchar nil) | 674 | (setq tchar nil) |
| 641 | (gnus-score-insert-help "Match type" legal-types 2))) | 675 | (gnus-score-insert-help "Match type" legal-types 2))) |
| @@ -651,15 +685,19 @@ current score file." | |||
| 651 | (message "")) | 685 | (message "")) |
| 652 | (setq pchar (or pchar ?t))) | 686 | (setq pchar (or pchar ?t))) |
| 653 | 687 | ||
| 688 | (setq header-string | ||
| 689 | (format "%s permanence (%s?): " (if increase "Increase" "Lower") | ||
| 690 | (mapconcat (lambda (s) (char-to-string (car s))) | ||
| 691 | char-to-perm ""))) | ||
| 692 | |||
| 654 | ;; We continue reading. | 693 | ;; We continue reading. |
| 655 | (while (not pchar) | 694 | (while (not pchar) |
| 656 | (if mimic | 695 | (if mimic |
| 657 | (progn | 696 | (progn |
| 658 | (sit-for 1) (message "%c %c %c-" prefix hchar tchar)) | 697 | (sit-for 1) (message "%c %c %c-" prefix hchar tchar)) |
| 659 | (message "%s permanence (%s?): " (if increase "Increase" "Lower") | 698 | (message header-string)) |
| 660 | (mapconcat (lambda (s) (char-to-string (car s))) | 699 | (setq pchar (gnus-read-char header-string |
| 661 | char-to-perm ""))) | 700 | (mapcar #'car char-to-perm))) |
| 662 | (setq pchar (read-char)) | ||
| 663 | (when (or (= pchar ??) (= pchar ?\C-h)) | 701 | (when (or (= pchar ??) (= pchar ?\C-h)) |
| 664 | (setq pchar nil) | 702 | (setq pchar nil) |
| 665 | (gnus-score-insert-help "Match permanence" char-to-perm 2))) | 703 | (gnus-score-insert-help "Match permanence" char-to-perm 2))) |