From: mark M <write2mark1@gmail.com>
To: John Yates <john@yates-sheets.org>
Cc: Eli Zaretskii <eliz@gnu.org>, Nick Helm <nick@tenpoint.co.nz>,
Emacs developers <emacs-devel@gnu.org>
Subject: Re: mode-line size and position indicator
Date: Thu, 24 Aug 2017 14:02:06 -0700 [thread overview]
Message-ID: <1c95c0be-e1c0-4361-a75e-8c659ef3a64e@marks-iPhone-6s-gold> (raw)
[-- Attachment #1: Type: text/plain, Size: 4801 bytes --]
Both Aquamacs and Emacs The latest version have started flickering quite a bit on opening any latex document with color or tables or formatting
>
> On Aug 24, 2017 at 12:26 PM, <John Yates (mailto:john@yates-sheets.org)> wrote:
>
>
>
> On Thu, Aug 24, 2017 at 12:55 PM, Eli Zaretskii wrote: > > Looks good, although there's a fundamental problem with putting on the > mode line an indicator that must use a significant part of the screen > estate to be useful: the mode line is pretty crowded these days, even > in the default configuration. After a futile effort at IBM to obtain an FSF copyright assignment I have given up and been too lazy to restart the effort with my new employer. Hence my .emacs (https://github.com/jsyjr/MyConfiguration.git ) is in the public domain. A couple months back I posted a mode-line widget that I have been using for some number of years. The relevant code is appended at the end of this message. Notable behavior: * Overlays proportional view of window in buffer onto line/column widget
* Supports the same mouse menu behavior as the original widget * Highlights left edge square bracket if BOB is visible * Highlights right edge square bracket if EOB is visible * Hysteresis to minimi
ze mode-line jitter This solution does not use any more mode-line real estate than the current line/column widget. . . . > I wonder whether it would have made sense to reuse the code we have > for computing the scroll-bar thumb. I am an inexperienced elisp hacker so I doubt that there is anything particularly useful or novel in my code. As the comments mention I was much inspired by past email discussions. The hardest part I found was the logic corresponding to Eli's scroll-bar thumb logic. I would love it if emacs offered essentially this functionality OOTB. /john ;;{{{ mode-line position-widget ;; Use a fancy widget to display buffer position on the mode line. ;; ------------------------------------------------------------------- ;; ;; Initial inspiration from an email thread between
David Engster's and ;; Drew Adams: ;; ;; http://lists.gnu.org/archive/html/emacs-devel/2010-03/msg00523.html ;; http://permalink.gmane.org/gmane.emacs.devel/122038 ;; ;; Further learnings from Lenn
art Borgman's sml-modeline.el ;; https://www.emacswiki.org/emacs/sml-modeline.el ;; ;; TODO: Change color if cursor exceeds limit column (defvar buffer-max-column-visited 1 "Accumulate max column visited to prevent mode-line jitter.") (make-variable-buffer-local 'buffer-max-column-visited) (defun my/position-widget () (let* ((c-n-m column-number-mode) (l-n-m line-number-mode) (wbeg (window-start)) (wend (window-end))) (save-restriction (widen) (let* ((eob-line (line-number-at-pos (point-max))) (wbeg-line (line-number-at-pos wbeg)) (wend-line (line-number-at-pos wend)) (widget (concat ;; Leading [ (if (= wbeg-line 1) #("[" 0 1 (face mode-line-highlight-bold)) "[") ;; Body (if (not (or l-n-m c-n-m)) (replace-regexp-in-string "%" "%%" (format-mode-line '(-3 "%P"))) (let* ((wlines (1+ (- wend-
line wbeg-line))) (expanded (format-mode-line (concat (cond ((not l-n-m) "") ((> 10 eob-line) "%1l") ((> 100 eob-line) "%2l") ((> 1000 eob-line) "%3l") ((> 10000 eob-line) "%4l") ((> 100000 e
ob-line) "%5l") ((> 1000000 eob-line) "%6l") (t "%7l")) (if (and l-n-m c-n-m) #("," 0 1 (face bold)) "") (cond ((not c-n-m) "") (t (let* ((max-col (max (current-column) buffer-max-column-visited)) (field (cond ((> 10 max-col) 3) ((> 100 max-col) 4) ((> 1000 max-col) 5) (t 6))) (cur-col (current-column)) (digits (cond ((> 10 cur-col) 1) ((> 100 cur-col) 2) ((> 1000 cur-col) 3) (t 4)))) (setq buffer-max-column-visited max-col) (substring "%c " 0 (- field digits)))))))) (len (length expanded)) (hilen (max 1 ; at least one column (min len ; no more than full string (round (/ (* wlines len) (float eob-line)))))) (lpad (round (/ (* wbeg-line (- len hilen)) (float (- eob-line wlines -2))))) (rpad (+ lpad hilen))) (put-text-property lpad rpad 'face 'mode-line-highlight expanded) expanded))
;; Trailing ] (if (= wend-line eob-line) #("]" 0 1 (face mode-line-highlight-bold)) "]")))) (propertize widget 'help-echo "Buffer position widget\nmouse-1: Line and Column Mode Menu" 'mouse-face 'mo
de-line-highlight 'local-map '(keymap (mode-line keymap (down-mouse-1 keymap (line-number-mode menu-item "Global Line Number Mode" line-number-mode :help "Toggle line number display" :button (:toggle . line-number-mode)) (column-number-mode menu-item "Global Column Number Mode" column-number-mode :help "Toggle column number display" :button (:toggle . column-number-mode)) "Control Line and Column Display Globally")))))))) (my/custom-set-variables '(mode-line-position '(:eval (my/position-widget)) t) ) ;;}}}
>
>
[-- Attachment #2: Type: text/html, Size: 7243 bytes --]
next reply other threads:[~2017-08-24 21:02 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-08-24 21:02 mark M [this message]
2017-08-25 6:27 ` mode-line size and position indicator Eli Zaretskii
-- strict thread matches above, loose matches on Subject: below --
2017-08-23 3:20 Nick Helm
2017-08-24 16:55 ` Eli Zaretskii
2017-08-24 19:26 ` John Yates
2017-08-25 2:47 ` Richard Stallman
2017-08-25 9:57 ` Nick Helm
2017-08-25 12:36 ` Eli Zaretskii
2017-08-26 7:50 ` Nick Helm
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1c95c0be-e1c0-4361-a75e-8c659ef3a64e@marks-iPhone-6s-gold \
--to=write2mark1@gmail.com \
--cc=eliz@gnu.org \
--cc=emacs-devel@gnu.org \
--cc=john@yates-sheets.org \
--cc=nick@tenpoint.co.nz \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.