commit acd2cb28ef63188bff31fc167ab007a051f99c17 (HEAD, refs/remotes/origin/master) Author: Ellington Santos Date: Tue May 26 11:37:04 2020 -0300 Improve battery status display via GNU/Linux sysfs * lisp/battery.el (battery-linux-sysfs): Support %b format. Improve the display of %p. (Bug#41542) Copyright-paperwork-exempt: yes diff --git a/lisp/battery.el b/lisp/battery.el index 7027b25448..b8855a8ce3 100644 --- a/lisp/battery.el +++ b/lisp/battery.el @@ -441,13 +441,15 @@ The following %-sequences are provided: %c Current capacity (mAh or mWh) %r Current rate %B Battery status (verbose) +%b Battery status, empty means high, `-' means low, + `!' means critical, and `+' means charging %d Temperature (in degrees Celsius) %p Battery load percentage %L AC line status (verbose) %m Remaining time (to charge or discharge) in minutes %h Remaining time (to charge or discharge) in hours %t Remaining time (to charge or discharge) in the form `h:min'" - (let (charging-state temperature hours + (let (charging-state temperature hours percentage-now ;; Some batteries report charges and current, other energy and power. ;; In order to reliably be able to combine those data, we convert them ;; all to energy/power (since we can't combine different charges if @@ -515,6 +517,8 @@ The following %-sequences are provided: energy-now (- energy-full energy-now)))) (setq hours (/ remaining power-now))))))) + (when (and (> energy-full 0) (> energy-now 0)) + (setq percentage-now (/ (* 100 energy-now) energy-full))) (list (cons ?c (cond ((or (> energy-full 0) (> energy-now 0)) (number-to-string (/ energy-now voltage-now))) (t "N/A"))) @@ -528,10 +532,13 @@ The following %-sequences are provided: "N/A")) (cons ?d (or temperature "N/A")) (cons ?B (or charging-state "N/A")) - (cons ?p (cond ((and (> energy-full 0) (> energy-now 0)) - (format "%.1f" - (/ (* 100 energy-now) energy-full))) - (t "N/A"))) + (cons ?b (or (and (string= charging-state "Charging") "+") + (and percentage-now (< percentage-now battery-load-critical) "!") + (and percentage-now (< percentage-now battery-load-low) "-") + "")) + (cons ?p (cond + ((and percentage-now (format "%.1f" percentage-now))) + (t "N/A"))) (cons ?L (cond ((battery-search-for-one-match-in-files (list "/sys/class/power_supply/AC/online" commit a984f39554cb33b9c2efbc843aabb283c69d503d Author: Pip Cet Date: Thu Jun 4 22:28:53 2020 +0000 Avoid zero-width glyphs and the resulting cursor artifacts * src/xdisp.c (fill_gstring_glyph_string): Handle unavailable glyphs. (append_composite_glyph): Mark unavailable glyphs. (gui_produce_glyphs): Make glyphs unavailable for zero-width compositions. (Bug#41645) diff --git a/src/xdisp.c b/src/xdisp.c index 327e8a183b..52f6ab8e70 100644 --- a/src/xdisp.c +++ b/src/xdisp.c @@ -27689,10 +27689,12 @@ fill_gstring_glyph_string (struct glyph_string *s, int face_id, struct glyph *glyph, *last; Lisp_Object lgstring; int i; + bool glyph_not_available_p; s->for_overlaps = overlaps; glyph = s->row->glyphs[s->area] + start; last = s->row->glyphs[s->area] + end; + glyph_not_available_p = glyph->glyph_not_available_p; s->cmp_id = glyph->u.cmp.id; s->cmp_from = glyph->slice.cmp.from; s->cmp_to = glyph->slice.cmp.to + 1; @@ -27707,7 +27709,8 @@ fill_gstring_glyph_string (struct glyph_string *s, int face_id, && glyph->u.cmp.automatic && glyph->u.cmp.id == s->cmp_id && glyph->face_id == face_id - && s->cmp_to == glyph->slice.cmp.from) + && s->cmp_to == glyph->slice.cmp.from + && glyph->glyph_not_available_p == glyph_not_available_p) { s->width += glyph->pixel_width; s->cmp_to = (glyph++)->slice.cmp.to + 1; @@ -27722,6 +27725,12 @@ fill_gstring_glyph_string (struct glyph_string *s, int face_id, s->char2b[i] = code & 0xFFFF; } + /* If the specified font could not be loaded, record that fact in + S->font_not_found_p so that we can draw rectangles for the + characters of the glyph string. */ + if (glyph_not_available_p) + s->font_not_found_p = true; + return glyph - s->row->glyphs[s->area]; } @@ -28918,7 +28927,7 @@ append_composite_glyph (struct it *it) glyph->overlaps_vertically_p = (it->phys_ascent > it->ascent || it->phys_descent > it->descent); glyph->padding_p = false; - glyph->glyph_not_available_p = false; + glyph->glyph_not_available_p = it->glyph_not_available_p; glyph->face_id = it->face_id; glyph->font_type = FONT_TYPE_UNKNOWN; if (it->bidi_p) @@ -30626,11 +30635,21 @@ gui_produce_glyphs (struct it *it) it->pixel_width = composition_gstring_width (gstring, it->cmp_it.from, it->cmp_it.to, &metrics); - if (it->glyph_row - && (metrics.lbearing < 0 || metrics.rbearing > metrics.width)) - it->glyph_row->contains_overlapping_glyphs_p = true; - it->ascent = it->phys_ascent = metrics.ascent; - it->descent = it->phys_descent = metrics.descent; + if (it->pixel_width == 0) + { + it->glyph_not_available_p = true; + it->phys_ascent = it->ascent; + it->phys_descent = it->descent; + it->pixel_width = face->font->space_width; + } + else + { + if (it->glyph_row + && (metrics.lbearing < 0 || metrics.rbearing > metrics.width)) + it->glyph_row->contains_overlapping_glyphs_p = true; + it->ascent = it->phys_ascent = metrics.ascent; + it->descent = it->phys_descent = metrics.descent; + } IT_APPLY_FACE_BOX(it, face); /* If face has an overline, add the height of the overline