-
Notifications
You must be signed in to change notification settings - Fork 21
feature: Add going to exact location on jumping back and forward #53
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
Open
pkradiator
wants to merge
1
commit into
astoff:main
Choose a base branch
from
pkradiator:main
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -348,7 +348,7 @@ already installed, reinstall it." | |
|
|
||
| (defun devdocs--revert-buffer (&rest _args) | ||
| "Refresh DevDocs buffer." | ||
| (devdocs--render (pop devdocs--stack))) | ||
| (devdocs--render (pop devdocs--stack) t)) | ||
|
|
||
| (defun devdocs-goto-target () | ||
| "Go to the original position in a DevDocs buffer." | ||
|
|
@@ -366,8 +366,9 @@ already installed, reinstall it." | |
| (interactive) | ||
| (unless (cadr devdocs--stack) | ||
| (user-error "No previous entry")) | ||
| (setcar devdocs--stack (cons (cons 'saved-point (point)) (car devdocs--stack))) | ||
| (push (pop devdocs--stack) devdocs--forward-stack) | ||
| (devdocs--render (pop devdocs--stack))) | ||
| (devdocs--render (pop devdocs--stack) t)) | ||
|
|
||
| (defun devdocs-go-forward () | ||
| "Go to the next entry in this DevDocs buffer." | ||
|
|
@@ -538,12 +539,13 @@ Interactively, read a page name with completion." | |
| (url-expander-remove-relative-links ;; undocumented function! | ||
| (concat (file-name-directory base) path)))))) | ||
|
|
||
| (defun devdocs--render (entry) | ||
| (defun devdocs--render (entry &optional skip-save) | ||
| "Render a DevDocs documentation entry, returning a buffer. | ||
|
|
||
| ENTRY is an alist like those in the entry index of the document, | ||
| possibly with an additional ENTRY.fragment which overrides the | ||
| fragment part of ENTRY.path." | ||
| fragment part of ENTRY.path. If SKIP-SAVE is non-nil, do not | ||
| save the current point into the outgoing stack entry." | ||
| (with-current-buffer (get-buffer-create "*devdocs*") | ||
| (unless (eq major-mode 'devdocs-mode) | ||
| (devdocs-mode)) | ||
|
|
@@ -559,6 +561,10 @@ fragment part of ENTRY.path." | |
| .doc.slug | ||
| (url-hexify-string (devdocs--path-file .path))) | ||
| devdocs-data-dir))) | ||
| (unless skip-save | ||
| (when devdocs--stack | ||
| (setcar devdocs--stack | ||
| (cons (cons 'saved-point (point)) (car devdocs--stack))))) | ||
| (erase-buffer) | ||
| ;; TODO: cl-progv here for shr settings? | ||
| (shr-insert-document | ||
|
|
@@ -571,7 +577,9 @@ fragment part of ENTRY.path." | |
| (setq-local list-buffers-directory (format-mode-line devdocs-header-line | ||
| nil nil | ||
| (current-buffer))) | ||
| (devdocs-goto-target) | ||
| (if .saved-point | ||
| (goto-char (min .saved-point (point-max))) | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Okay, good catch. But also (So really we should rather call |
||
| (devdocs-goto-target)) | ||
| (current-buffer)))) | ||
|
|
||
| (defun devdocs--internal-url-p (url) | ||
|
|
||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Do you mean
(push `(saved-point . ,(point)) (car devdocs--stack))?Also, we can name that property just
point.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.
Or better, actually:
(setf (alist-get 'saved-point (car devdocs--stack)) (point)).