alphapapa / dogears.el

Never lose your place in Emacs again
GNU General Public License v3.0
189 stars 7 forks source link

Dogears.el's behavior differs from Web Browsers and IDEs #27

Open chansey97 opened 2 weeks ago

chansey97 commented 2 weeks ago

Dogears' backward / forward behavior is different from browsers and other IDEs.

For example, set (setq dogears-position-delta 50) in init.el and put the following text in *scratch*.

Conferences       ....................................................................

Legal environment ....................................................................

See also          ....................................................................

Notes             ....................................................................

References        ....................................................................

Further reading   ....................................................................

External links    ....................................................................

Check the behavior:

  1. Put the cursor at "External links" and M-x dogears-remember
  2. Put the cursor at "Further reading" and M-x dogears-remember
  3. Put the cursor at "References" and M-x dogears-remember
  4. M-x dogears-back, the cursor will jump to "Further reading"
  5. Put the cursor at "Conferences" and M-x dogears-remember
  6. M-x dogears-back, the cursor will jump to "Further reading" (GOOD)
  7. M-x dogears-forward, the cursor will jump to "References" (BAD)
  8. M-x dogears-forward, the cursor will jump to "Conferences" (GOOD, but should skip step 7)

Why the step 7 is bad? Because it is inconsistent with Web Browsers. You can try the same steps in https://en.wikipedia.org/wiki/Wiki via Firefox.

  1. Click "External links" link
  2. Click "Further reading" link
  3. Click "References" link
  4. Click "Go back" button, the web page jump to "Further reading"
  5. Click "Conferences" link
  6. Click "Go back" button, the web page jump to "Further reading" (GOOD)
  7. Click "Go forward" button, the web page jump to "Conferences" (GOOD)

I also tried some IDEs (e.g. IntelliJ IDEA), they follow Firefox's behavior.

Thanks to the clean code of dogears.el, adapting it to match the behavior of Web Browsers might be not difficult. For example, dogears-remember can delete old places before dogears-position.

Do you think it is necessary for dogears.el to use the Web Browser behavior? Or be an option?

Just for discussion.

chansey97 commented 2 weeks ago

better-jumper has a better-jumper-add-jump-behavior option (for replace and append).

alphapapa commented 2 weeks ago

Dogears tries to roughly imitate browsers' behavior, but it's not necessarily intended to work exactly the same way. The list of places is added to, but places are not popped off the list as they are returned to; it's closer to an Emacs-style ring than a browser's back-button history list.

Technically I suppose browsers don't pop items off the list as the user goes back, but if the user goes back a few pages and then clicks a link on a page, the old "forward history" is discarded. So potentially we could implement a tree of places and fork it, similarly to the Emacs undo list (e.g. visualized with vundo). However, that would mean a lot of additional complexity in implementation and UI, which I doubt would be worth it.

Having said that, there may be some lingering bugs in this functionality. For example, maybe dogears-remember should update dogears-position when it remembers a new place; I wonder how doing that would affect the example behavior you showed.

I appreciate your scrutiny of these features. Having written Dogears, and while I have dogears-mode activated all the time, I don't actually use it to go forward/back as much as I expected to, so it needs more testing to wring out these little issues.