I'm trying to write my own backend for a certain tool language that has no repl. Hence, I thought it would be the best idea to parse the documentation and store it as a hash table (I'm open to other suggestions, I'm fairly new to Emacs). In general this works fine, the problems arise when the documentation is longer than a display. In this case, I would like to use scroll-other-window like anywhere else to scroll the documentation down, but it immediately jumps back to the top.

This is the basic structure of my backend:

(defconst my--constants
  (list "asdf"

(defconst my--doc-buffer
     size 3
     test equal
     data("asdf" "Test."
          "bsdf" "Doing\nfine."
          "csdf" "T\nh\ni\ns\n \ni\ns\n \nw\nh\ne\nr\ne\n \ni\nt\n \ng\ne\nt\ns\n \nr\ne\na\nl\nl\ny\n \nm\ne\ns\ns\ny\n.\n \nE\nv\ne\nn\n \nw\ni\nt\nh\n \ns\nc\nr\no\nl\nl\n-\no\nt\nh\ne\nr\n-\nw\ni\nn\nd\no\nw\n \ni\nt\n \nj\nu\nm\np\ns\n \nb\na\nc\nk\n.")))

(define-derived-mode my-mode prog-mode "My")

(defun my-completion-at-point ()
  (let ((bounds (bounds-of-thing-at-point 'word)))
    (when bounds
      (list (car bounds)
            (cdr bounds)
            :exclusive 'no
            :sorted (lambda (cand) t)
            (lambda (cand)
              (company-doc-buffer (gethash cand my--doc-buffer)))))))

(add-hook 'completion-at-point-functions 'my-completion-at-point)

When company-show-doc-buffer is called upon csdf, scroll-other-window won't do it's job properly. Instead it immediately jumps back to the head.

Are those \n linebreaks the wrong approach? Am I missing something else? Unfortunately I couldn't find any other backends that use doc-buffers in an offline table. Is it actually the way to go, to use a company-doc-buffer, or is there a more generic thing available/recommended?

  • 1
    Works for me. Are you sure you're calling scroll-other-window? – Dmitry Oct 23 '19 at 10:39
  • 1
    Thanks a lot for testing, it made me rethink my company configuration. – knusprjg Oct 23 '19 at 14:05

I finally figured out the culprit: company-quickhelp-mode was enabled in my setup which evidently triggered the doc-buffer all the time to reload. After disabling, everything works as expected. I'll try to solve this issue also with company-quickhelp and add my results here later.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.