-
Notifications
You must be signed in to change notification settings - Fork 27
New UI #63
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
New UI #63
Conversation
basil-conto
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you very much for the contribution! There is definitely interest in improving the UI.
I won't have time to review this carefully for a little while, so here are some thoughts after a quick scan of the changes.
-
The topic of improving the UI has been brought up before. Have you looked over #44, #45, and #55? Since those discussions, I have also learned of another attractive UI/MVC framework that is built into Emacs, namely
ewoc:(info "(elisp) Abstract Display") -
Ideally the choice of UI should be configurable via a user option. Similarly, we should try to avoid changing default key bindings (and their effects) if possible.
| (when size | ||
| (push `(:height ,size) props)) | ||
| (when font-color | ||
| (push `(:foreground ,font-color) props)) | ||
| (when background-color | ||
| (push `(:background ,background-color) props)) | ||
| (when props | ||
| (put-text-property start end 'face (apply #'append props)))))) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be more configurable and play better with Font Lock if we used named faces defined via defface rather than ad-hoc anonymous faces. Ideally the default colours would adapt well to the user's background mode etc.
hackernews.el
Outdated
| :notify (lambda (&rest _) | ||
| (hackernews-top-stories)) | ||
| :help-echo "View top stories" | ||
| " 🔥 Top ") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think we can assume that emoji will always be displayable in the user's system/font, so this should degrade gracefully or at least be configurable. IIRC more recent Emacs versions introduced a mechanism for this, namely define-icon or similar: (info "(elisp) Icons")
| (let ((separator-regex (concat "^" (regexp-quote (hackernews--string-separator)) "$"))) | ||
| (if (search-forward-regexp separator-regex nil t) | ||
| (forward-line 2) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My first reaction is that this is too tightly coupled with the display format. I would prefer to avoid search-based motion, instead relying on either some feature of the UI, or some marker (e.g. text property) that we place in the buffer that is independent of how the buffer is displayed.
| (inhibit-read-only t)) | ||
| (feed (hackernews--get :feed)) | ||
| (feed-name (hackernews--feed-name feed)) | ||
| (is-first-load (= (point-max) 1))) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In general there's no need to compare against concrete position values in Elisp. If you want to check whether the narrowed portion of the buffer is empty, you can compare point-min to point-max; and for checking whether the buffer is empty irrespective of narrowing, there is buffer-size.
| (is-first-load (= (point-max) 1))) | ||
|
|
||
| ;; Temporarily disable read-only mode | ||
| (read-only-mode -1) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not bind inhibit-read-only?
| ;; Disable line numbers | ||
| (when (fboundp 'display-line-numbers-mode) | ||
| (display-line-numbers-mode 0)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this needed? Ideally we shouldn't have to override user preferences.
| (when (and hackernews-enable-visual-fill-column | ||
| (require 'visual-fill-column nil t)) | ||
| (setq-local visual-fill-column-center-text t) | ||
| (setq-local visual-fill-column-width hackernews-display-width) | ||
| (visual-fill-column-mode 1)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why does hackernews need to be aware of visual-fill-column-mode, and load and enable it explicitly? Can't the user enable the minor mode as desired via hackernews-mode-hook? If the setup is nontrivial we can always document it in our README/wiki.
| ;; Activate the keymap | ||
| (use-local-map hackernews-mode-map)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this needed? Usually this is done automatically by define-derived-mode.
| ;; Kill local variables BEFORE disabling read-only (like Lobsters) | ||
| (kill-all-local-variables) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this needed?
| ;; Temporarily disable read-only mode | ||
| (read-only-mode -1) | ||
|
|
||
| ;; Clear buffer | ||
| (let ((inhibit-read-only t)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this needed given the subsequent inhibit-read-only?
| ;; Keywords: comm hypermedia news | ||
| ;; Version: 0.7.1 | ||
| ;; Version: 0.8.0 | ||
| ;; Package-Requires: ((emacs "24.3")) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Either:
- remove the versions lower than 24.3 from
.github/workflows/build.yml; or - add a dependency on the
cl-libcompatibility package from GNU ELPA: https://elpa.gnu.org/packages/cl-lib.html
Personally I am happy to raise the minimum required Emacs version as needed, given that the hackernews package talks to remote third-party machines over the network.
|
Thank you very much for the detailed review and feedback! Previous discussions and ewoc: I'll review those now. The ewoc framework sounds interesting; I wasn't familiar with it. Regarding specific code issues:
Well...would you prefer that I:
|
That would be amazing for backward compatibility, which though a general goal of the Emacs project, may or may not be our highest priority for the If it proves too much of a hassle we can always reconsider.
Markers can degrade Emacs redisplay performance (at least this was the case historically in Emacs, though more recent changes to Emacs internals may have mitigated this). The penalty may be negligible in the case of However, if the Widget/EWOC/etc. library provides functions for locating UI elements, then I think we should prefer that over a custom solution.
It's completely up to you, AFAIC there's no harm in leaving this PR open and in progress. Thanks again, and happy hacking! :) |
Would that be interesting?