all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* bug#54774: 28.1; ansi-color with no colors in Emacs-28
@ 2022-04-07 19:49 Thierry Volpiatto
  2022-04-07 20:10 ` Thierry Volpiatto
  2022-04-08 13:23 ` Lars Ingebrigtsen
  0 siblings, 2 replies; 10+ messages in thread
From: Thierry Volpiatto @ 2022-04-07 19:49 UTC (permalink / raw)
  To: 54774

[-- Attachment #1: Type: text/plain, Size: 10871 bytes --]


Hello,
it seems using ansi-color-apply in Emacs-28 is not working properly,
there is no colors.  In Emacs-29 it is working properly (very nice)
without needing a workaround used previously in emacs-27 (code commented).
See code below to reproduce and Screenshots attached.

Thanks.

#+begin_src elisp

(defvar wttr-weather-history nil)
(defvar wttr-weather-default-location "Guillestre")
(defvar wttr-weather-last-location nil)
;;;###autoload
(defun wttr-weather (place)
  "Weather forecast with wttr.in.
With a prefix arg refresh buffer if some.
See <https://github.com/chubin/wttr.in>."
  (interactive (list (read-string (format "Place (%s): "
                                          wttr-weather-default-location)
                                  nil
                                  'wttr-weather-history
                                  wttr-weather-default-location)))
  (let ((buf (get-buffer-create (format "*wttr.in %s*" place))))
    (switch-to-buffer buf)
    (when current-prefix-arg
      (set (make-local-variable 'wttr-weather-last-location) nil))
    (unless wttr-weather-last-location
      (wttr-weather-update place)
      (wttr-weather-mode)
      (set (make-local-variable 'wttr-weather-last-location) place))))

(defun wttr-weather-update (place)
  (let* ((inhibit-read-only t)
         ansi
         (data
          (with-temp-buffer
            (call-process
             "curl" nil '(t t) nil
             "-s" (format "fr.wttr.in/~%s?m" (shell-quote-argument place)))
            (goto-char (point-min))
            ;; Commenting this part which is for Emacs-27.
            ;; `ansi' is not set but it is not a problem for just
            ;; debugging this.
            ;;
            ;; (while (re-search-forward "38;5;\\([0-9]+\\)m" nil t)
            ;;   ;; If we have ansi sequences, that's mean we had weather
            ;;   ;; output, otherwise we have a simple message notifying
            ;;   ;; weather report is not available.
            ;;   (setq ansi t)
            ;;   ;; Need a 256 color ansi library, emacs supports only basic
            ;;   ;; ansi colors as now, so replace all 38;5 foreground
            ;;   ;; specs by simple ansi sequences.
            ;;   (replace-match (pcase (match-string 1)
            ;;                    ("154" "32")
            ;;                    ("190" "31")
            ;;                    ("118" "32")
            ;;                    ("208" "37")
            ;;                    ("202" "34")
            ;;                    ("214" "35")
            ;;                    ("220" "36")
            ;;                    ("226" "33")
            ;;                    (r     r))
            ;;                  t t nil 1))
            (ansi-color-apply (buffer-string)))))
    (erase-buffer)
    (save-excursion
      (if data
          (insert data)
        ;; Probaly check error status instead (it is 52).
        (insert "Empy reply from server"))
      (forward-line -1)
      (when (and ansi ; Keep notification when no weather report.
                 (re-search-backward "^$" nil t))
        (delete-region (point) (point-max))))
    (while (re-search-forward "\\s\\" (point-at-eol) t) (replace-match ""))
    (goto-char (point-at-eol))
    (insert (format-time-string " le %d/%m/%Y à %H:%M:%S"))))

(defun wttr-weather-revert-fn (_ignore-auto _no_confirm)
  (wttr-weather-update wttr-weather-last-location))

(define-derived-mode wttr-weather-mode special-mode "wttr"
  (make-local-variable 'wttr-weather-last-location)
  (set (make-local-variable 'revert-buffer-function) 'wttr-weather-revert-fn))

#+end_src




In GNU Emacs 28.1 (build 2, x86_64-pc-linux-gnu, GTK+ Version 3.24.20, cairo version 1.16.0)
 of 2022-04-05 built on IPad-S340
Windowing system distributor 'The X.Org Foundation', version 11.0.12013000
System Description: Linux Mint 20.2

Configured using:
 'configure CFLAGS=-O8 --with-mailutils --with-cairo
 --with-native-compilation'

Configured features:
ACL CAIRO DBUS FREETYPE GIF GLIB GMP GNUTLS GPM GSETTINGS HARFBUZZ JPEG
JSON LCMS2 LIBOTF LIBSELINUX LIBSYSTEMD LIBXML2 M17N_FLT MODULES
NATIVE_COMP NOTIFY INOTIFY PDUMPER PNG RSVG SECCOMP SOUND THREADS TIFF
TOOLKIT_SCROLL_BARS X11 XDBE XIM XPM GTK3 ZLIB

Important settings:
  value of $LANG: fr_FR.UTF-8
  locale-coding-system: utf-8-unix

Major mode: ƐĽ

Minor modes in effect:
  bug-reference-prog-mode: t
  global-undo-tree-mode: t
  undo-tree-mode: t
  psession-mode: t
  psession-savehist-mode: t
  global-git-gutter-mode: t
  git-gutter-mode: t
  display-time-mode: t
  winner-mode: t
  helm-epa-mode: t
  helm-descbinds-mode: t
  helm-adaptive-mode: t
  helm-mode: t
  helm-minibuffer-history-mode: t
  helm-ff-icon-mode: t
  shell-dirtrack-mode: t
  helm-popup-tip-mode: t
  async-bytecomp-package-mode: t
  dired-async-mode: t
  minibuffer-depth-indicate-mode: t
  override-global-mode: t
  tooltip-mode: t
  global-eldoc-mode: t
  eldoc-mode: t
  show-paren-mode: t
  mouse-wheel-mode: t
  file-name-shadow-mode: t
  global-font-lock-mode: t
  font-lock-mode: t
  auto-composition-mode: t
  auto-encryption-mode: t
  auto-compression-mode: t
  column-number-mode: t
  line-number-mode: t
  transient-mark-mode: t

Load-path shadows:
None found.

Features:
(epa-mail face-remap char-fold image-file image-converter helm-x-files
helm-for-files addressbook-bookmark mu4e-config org-mu4e mu4e-contrib
mu4e-patch mu4e mu4e-org mu4e-view gnus-art mm-uu mml2015 mm-view
mml-smime smime dig gnus-sum gnus-group gnus-undo gnus-start gnus-dbus
gnus-cloud nnimap nnmail mail-source utf7 netrc nnoo gnus-spec gnus-int
gnus-range gnus-win mu4e-main mu4e-headers mu4e-lists mu4e-compose
mu4e-draft mu4e-actions smtpmail mu4e-search mu4e-bookmarks mu4e-mark
mu4e-message shr kinsoku svg flow-fill hl-line mu4e-contacts mu4e-update
mu4e-folders mu4e-server mu4e-context mu4e-vars mu4e-helpers ido
mu4e-meta shadow sort mail-extr emacsbug sendmail tramp-archive
tramp-gvfs tramp-cache zeroconf dbus helm-command flymake-proc flymake
project make-mode vc-filewise vc-rcs conf-mode ledger-config ledger-mode
ledger-check ledger-texi ledger-test ledger-sort ledger-report
ledger-reconcile ledger-occur ledger-fonts ledger-fontify ledger-state
ledger-complete ledger-schedule ledger-init ledger-xact ledger-post
ledger-exec ledger-navigate eshell esh-cmd esh-ext esh-opt esh-proc
esh-io esh-arg esh-module esh-groups esh-util ledger-context
ledger-commodities ledger-regex markdown-mode bug-reference jka-compr
sh-script smie executable naquadah-theme solar cal-dst holidays
hol-loaddefs tv-utils osm dom yaml-mode undo-tree diff queue
rainbow-mode color psession frameset log-view pcvs-util pcmpl-git
cl-indent ffap thingatpt autocrypt-message message rmc puny rfc822 mml
mml-sec mm-decode mm-bodies mm-encode mail-parse rfc2231 mailabbrev
gmm-utils mailheader autocrypt-gnus gnus nnheader gnus-util rmail
rmail-loaddefs rfc2047 rfc2045 mail-utils mm-util mail-prsvr
autocrypt-mu4e autocrypt ietf-drums config-w3m git-gutter mule-util appt
diary-lib diary-loaddefs gud pcomplete-extension pcmpl-unix pcmpl-gnu
iterator pcase wdired dired-extension org-config ob-gnuplot org-crypt
net-utils time winner autotest-mode autoconf-mode woman man ediff
ediff-merg ediff-mult ediff-wind ediff-diff ediff-help ediff-init
ediff-util init-helm helm-ls-git vc-git diff-mode vc vc-dispatcher
helm-fd epa derived epg rfc6068 epg-config helm-epa helm-imenu imenu
helm-elisp-package helm-find helm-org org ob ob-tangle ob-ref ob-lob
ob-table ob-exp org-macro org-footnote org-src ob-comint org-pcomplete
org-list org-faces org-entities noutline outline org-version
ob-emacs-lisp ob-core ob-eval org-table oc-basic bibtex ol org-keys oc
org-compat advice org-macs org-loaddefs cal-menu calendar cal-loaddefs
helm-external isearch-light helm-descbinds helm-wikipedia all-the-icons
all-the-icons-faces data-material data-weathericons data-octicons
data-fileicons data-faicons data-alltheicons cus-edit wid-edit
helm-ipython helm-elisp helm-eval edebug backtrace find-func python
tramp-sh helm-bookmark helm-net xml helm-info bookmark pp helm-adaptive
helm-mode helm-misc helm-files image-dired image-mode exif filenotify
tramp tramp-loaddefs trampver tramp-integration files-x tramp-compat
shell pcomplete parse-time iso8601 time-date ls-lisp helm-buffers
helm-occur helm-tags helm-locate helm-grep wgrep-helm wgrep grep compile
text-property-search comint ansi-color ring helm-regexp format-spec
helm-utils helm-help helm-types helm-extensions-autoloads helm-config
helm-autoloads helm helm-core async-bytecomp helm-global-bindings
helm-easymenu helm-source helm-multi-match helm-lib dired-async
dired-aux dired dired-loaddefs async popup diminish mb-depth server comp
comp-cstr warnings rx cl-extra help-mode edmacro kmacro avoid cus-load
use-package use-package-ensure use-package-delight use-package-diminish
use-package-bind-key bind-key easy-mmode use-package-core finder-inf
package browse-url url url-proxy url-privacy url-expand url-methods
url-history url-cookie url-domsuf url-util mailcap url-handlers
url-parse auth-source cl-seq eieio eieio-core cl-macs eieio-loaddefs
password-cache json subr-x map url-vars seq byte-opt gv bytecomp
byte-compile cconv cl-loaddefs cl-lib info w3m-load iso-transl tooltip
eldoc paren electric uniquify ediff-hook vc-hooks lisp-float-type
elisp-mode mwheel term/x-win x-win term/common-win x-dnd tool-bar dnd
fontset image regexp-opt fringe tabulated-list replace newcomment
text-mode lisp-mode prog-mode register page tab-bar menu-bar rfn-eshadow
isearch easymenu timer select scroll-bar mouse jit-lock font-lock syntax
font-core term/tty-colors frame minibuffer cl-generic cham georgian
utf-8-lang misc-lang vietnamese tibetan thai tai-viet lao korean
japanese eucjp-ms cp51932 hebrew greek romanian slovak czech european
ethiopic indian cyrillic chinese composite emoji-zwj charscript charprop
case-table epa-hook jka-cmpr-hook help simple abbrev obarray
cl-preloaded nadvice button loaddefs faces cus-face macroexp files
window text-properties overlay sha1 md5 base64 format env code-pages
mule custom widget hashtable-print-readable backquote threads dbusbind
inotify lcms2 dynamic-setting system-font-setting font-render-setting
cairo move-toolbar gtk x-toolkit x multi-tty make-network-process
native-compile emacs)

Memory information:
((conses 16 893084 166497)
 (symbols 48 43805 13)
 (strings 32 244568 28635)
 (string-bytes 1 6976950)
 (vectors 16 86016)
 (vector-slots 8 2303151 205471)
 (floats 8 2821 2894)
 (intervals 56 12355 7408)
 (buffers 992 156))
<#secure method=pgpmime mode=sign>

-- 
Thierry

[-- Attachment #2: Capture d’écran_2022-04-07_21-21-51.png --]
[-- Type: image/png, Size: 156007 bytes --]

[-- Attachment #3: Capture d’écran_2022-04-07_21-35-10.png --]
[-- Type: image/png, Size: 148605 bytes --]

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2022-04-10 12:01 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-04-07 19:49 bug#54774: 28.1; ansi-color with no colors in Emacs-28 Thierry Volpiatto
2022-04-07 20:10 ` Thierry Volpiatto
2022-04-07 20:24   ` Thierry Volpiatto
2022-04-08 13:23 ` Lars Ingebrigtsen
2022-04-08 17:48   ` Thierry Volpiatto
2022-04-08 18:23   ` Jim Porter
2022-04-09  7:25     ` Thierry Volpiatto
2022-04-09 17:31       ` Jim Porter
2022-04-09 18:18         ` Thierry Volpiatto
2022-04-10 12:01           ` Lars Ingebrigtsen

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.