-
-
Notifications
You must be signed in to change notification settings - Fork 1
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
Feature request: Line number 1 in front of first line of text #17
Comments
Thanks for submitting this request. Unfortunately it looks like making this happen would require modifying the Emacs C source code, which isn't something that could be covered in a patch to the More details: The line numbers are displayed by setting the |
Thanks for looking into it :) |
I'm going to re-open this issue because it would be nice to have it implemented eventually as a longer-term issue, either by myself or someone else willing to help. It will likely require additional functionality to be added to the Emacs C core and then could be available in a future Emacs version. I will eventually either open an issue with the Emacs devel mailing list for this or try to contribute the change myself but I will have to wait till I have more time to spend understanding the Emacs C core first which I've only briefly looked at before. |
@trevorpogue a hacky workaround for this issue in my case has been to use (let ((ln-pos (line-number-at-pos)))
(if (eq ln-pos 1)
(run-with-idle-timer 0 nil #'sit-for 0))) in my case, I have a lot of custom keybindings for buffer navigation with functions that constantly call I've tried to find some sort of universal way of calling this, like using: (defadvice linum-update (after fix-topspace-linum-update activate)
...)
(ad-activate 'linum-update) but even though it executes accordingly, it doesn't seem to work at all. Even adding a ton of delay to just some food for thought if anyone is interested in exploring further. |
Thanks for the tip! And I also use many hooks calling Anyways, I tried your code snippet, calling |
@trevorpogue I was getting This may have something to do with the fact I also change the face of the line numbers when highlighted, to complement (require 'hl-line)
(defface custom-linum-hl
`((t :inherit linum :background ,(face-background 'hl-line nil t)))
"Face for the current line number."
:group 'linum)
(defvar custom-linum-format-string "%3d ")
(add-hook 'linum-before-numbering-hook 'custom-linum-get-format-string)
(defun custom-linum-get-format-string ()
(let* ((width (1+ (length (number-to-string
(count-lines (point-min) (point-max))))))
(format (concat "%" (number-to-string width) "d ")))
(setq custom-linum-format-string format)))
(defvar custom-linum-current-line-number 0)
(setq linum-format 'custom-linum-format)
(defun custom-linum-format (line-number)
(propertize (format custom-linum-format-string line-number) 'face
(if (eq line-number custom-linum-current-line-number)
'custom-linum-hl
'linum)))
(defadvice linum-update (around custom-linum-update)
(let ((custom-linum-current-line-number (line-number-at-pos)))
ad-do-it))
(ad-activate 'linum-update) example of one of my binds (I am using (defun custom-up-bind()
(interactive)
(call-interactively 'previous-line)
(call-interactively 'recenter)
(call-interactively 'move-end-of-line)
(let ((ln-pos (line-number-at-pos)))
(if (eq ln-pos 1)
(sit-for 0)))) with my configuration, I can now only reproduce the line numbering bug with specific mouse actions. perhaps the real solution might be changing/updating the face? |
This is encouraging because I didn't actually think it was possible to ever have the |
@trevorpogue to clarify, this is with my configuration predates |
@jarcode-foss okay that makes more sense and is good to know. I was able to reproduce your bug now and I seem to have a fix for it. There is a function So, anyone who wants this feature can use |
For ;; Zen mode
(defun zen-mode-bodge ()
(let ((ov (make-overlay 1 1 nil t t)))
(overlay-put ov 'priority 9999999)
(overlay-put ov 'before-string (propertize " 1 " 'face 'line-number))
(overlay-put ov 'zen--remove-from-buffer-tag t))
(let ((ov (make-overlay 1 2)))
(overlay-put ov 'display-line-numbers-disable t)
(overlay-put ov 'zen--remove-from-buffer-tag t)))
(defun zen-mode-clear ()
(remove-overlays 1 2 'zen--remove-from-buffer-tag t))
;; install hooks
(advice-add 'topspace--enable :after #'zen-mode-bodge)
(advice-add 'topspace--disable :after #'zen-mode-clear)
There don't seem to be any hooks defined so I am using |
Is your feature request related to a problem? Please describe.
With line numbers enabled, line number 1 is currently shown at the top of the buffer. This is perfectly workable but it would be nice if it was in front of the actual first line of text.
Describe the solution you'd like
Have line number 1 be in front of the first line of text.
The text was updated successfully, but these errors were encountered: