Coder Social home page Coder Social logo

helm-pages's People

Contributors

david-christiansen avatar mrbliss avatar porglezomp avatar syohex avatar xiongtx avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

helm-pages's Issues

Incorrect definition of "beginning of page"

Problem

There is an issue with the current value of POS in helm-pages-get-pages. According to the documentation, POS is the beginning of a page. However, except for the first page, the value of POS is actually the position before the page-delimiter.

Example

For example, suppose that ^L is the page-delimiter, and we have a buffer as follows:

First page
Foo
^L
Second page
Bar
^L
Third page
Baz

Let (n) be the position of the beginning of the nth page. Then I would expect:

(1)First page
Foo
^L
(2)Second page
Bar
^L
(3)Third page
Baz

Instead, we currently have:

(1)First page
Foo
(2)^L
Second page
Bar
(3)^L
Third page
Baz

Consequence

The consequence of this inconsistency is that the helm-pages-goto-page and helm-pages-narrow-to-page functions have to call forward-line to position the cursor as the the user would expect, but this causes the cursor for the first page to be positioned on the second line, not the first.

Try it: call helm-pages-goto-page on First page in the above example while using helm-pages. Let (|) indicate the cursor. Then I would expect:

(|)First page
Foo
^L
Second page
Bar
^L
Third page
Baz

Instead, we currently have:

First page
(|)Foo
^L
Second page
Bar
^L
Third page
Baz

Solution

  • Change helm-pages-get-pages to:
(defun helm-pages-get-pages ()
  "Get a list of (POS . HEADER) pairs, where POS denotes the
beginning of a page and HEADER is the contents of the first
non-blank line in that page."
  (with-helm-current-buffer
    (save-excursion
      (save-restriction
    (widen)
    (goto-char (point-min))
    (let ((pages (list (cons (point)
                 (helm-pages-get-next-header)))))
      (while (re-search-forward page-delimiter nil t)
            (forward-line)
        (push (cons (point)
            (helm-pages-get-next-header))
          pages))
      (nreverse pages))))))
  • Remove forward-line from helm-pages-goto-page and helm-pages-narrow-to-page.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.