Subject: bug#22424: 24.5; erc-faces-in gives inconsistent results

From: Kevin Brubeck Unhammer <[email-masked]>
Date: Thu, 21 Jan 2016 09:01:29 +0100

erc-track.el defines

(defun erc-faces-in (str)
  "Return a list of all faces used in STR."
  (let ((i 0)
	(m (length str))
	(faces (erc-list (get-text-property 0 'face str)))
	cur)
    (while (and (setq i (next-single-property-change i 'face str m))
		(not (= i m)))
      (and (setq cur (get-text-property i 'face str))
	   (not (member cur faces))
	   (push cur faces)))
    faces))

Due to the use of `erc-list', this will give different levels of lists
depending on whether the *first* face seen is e.g. (cons
'foreground-color "red") or a symbol 'erc-foo-face.

One input might get you

    '((foreground-color . "red") erc-foo-face)

while if you reverse that input, you might get

    '(erc-foo-face foreground-color . "red")

The two are not equivalent, and the latter can lead to errors in
#'erc-track-modified-channels (at least if you (like me) have a lot of
customisations to nick colouring).

Here is an alternative function that seems to do the right thing:

(defun erc-faces-in (str)
     "Return a list of all faces used in STR."
     (let ((i 0)
           (m (length str))
           (faces (let ((face1 (get-text-property 0 'face str)))
                    (when face1 (list face1))))
           cur)
       (while (and (setq i (next-single-property-change i 'face str m))
                   (not (= i m)))
         (and (setq cur (get-text-property i 'face str))
              (not (member cur faces))
              (push cur faces)))
       faces))

In GNU Emacs 24.5.1 (x86_64-unknown-linux-gnu, X toolkit, Xaw scroll bars)
 of 2015-09-22 on kiwiarch
Configured using:
 `configure --prefix=/usr --sysconfdir=/etc --libexecdir=/usr/lib
 --localstatedir=/var --with-x-toolkit=lucid --with-xft --without-gconf
 --without-gsettings 'CFLAGS=-march=x86-64 -mtune=generic -O2 -pipe
 -fstack-protector-strong --param=ssp-buffer-size=4'
 CPPFLAGS=-D_FORTIFY_SOURCE=2
 LDFLAGS=-Wl,-O1,--sort-common,--as-needed,-z,relro'

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

Major mode: Emacs-Lisp

Minor modes in effect:
  magit-auto-revert-mode: t
  auto-revert-mode: t
  global-git-commit-mode: t
  async-bytecomp-package-mode: t
  shell-dirtrack-mode: t
  erc-capab-identify-mode: t
  erc-log-mode: t
  erc-track-score-mode: t
  erc-autoaway-mode: t
  diff-auto-refine-mode: t
  jabber-activity-mode: t
  erc-list-mode: t
  erc-menu-mode: t
  erc-autojoin-mode: t
  erc-ring-mode: t
  erc-networks-mode: t
  erc-pcomplete-mode: t
  erc-track-mode: t
  erc-track-minor-mode: t
  erc-match-mode: t
  erc-button-mode: t
  erc-fill-mode: t
  erc-stamp-mode: t
  erc-netsplit-mode: t
  erc-irccontrols-mode: t
  erc-noncommands-mode: t
  erc-move-to-prompt-mode: t
  erc-readonly-mode: t
  aggressive-indent-mode: t
  company-mode: t
  eldoc-mode: t
  flycheck-mode: t
  auto-complete-mode: t
  elisp-slime-nav-mode: t
  evil-surround-mode: t
  show-smartparens-mode: t
  smartparens-global-mode: t
  smartparens-strict-mode: t
  smartparens-mode: t
  evil-leader-mode: t
  evil-mode: t
  global-undo-tree-mode: t
  undo-tree-mode: t
  evil-local-mode: t
  rich-minority-mode: t
  display-time-mode: t
  global-fasd-mode: t
  recentf-mode: t
  ido-everywhere: t
  delete-selection-mode: t
  cua-mode: t
  show-paren-mode: t
  global-whitespace-mode: t
  override-global-mode: t
  electric-indent-mode: t
  mouse-wheel-mode: t
  global-prettify-symbols-mode: t
  prettify-symbols-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

Recent messages:
Mark set
Error during redisplay: (eval (offlineimap-mode-line)) signaled (wrong-type-argument arrayp nil) [2 times]
Mark set
Error during redisplay: (eval (offlineimap-mode-line)) signaled (wrong-type-argument arrayp nil) [6 times]
Mark set
Error during redisplay: (eval (offlineimap-mode-line)) signaled (wrong-type-argument arrayp nil) [4 times]
Mark set
Error during redisplay: (eval (offlineimap-mode-line)) signaled (wrong-type-argument arrayp nil) [7 times]
ad-Advice-delete-char: Text is read-only [2 times]
Error during redisplay: (eval (offlineimap-mode-line)) signaled (wrong-type-argument arrayp nil) [16 times]

Load-path shadows:
/home/kiwibird/.emacs.d/elpa/helm-20160115.2200/helm-multi-match hides /home/kiwibird/.emacs.d/elpa/helm-core-20160116.2343/helm-multi-match
/home/kiwibird/.emacs.d/elpa/magit-20160117.2129/magit-popup hides /home/kiwibird/.emacs.d/elpa/magit-popup-20160117.1513/magit-popup
/home/kiwibird/.opam/4.02.1/lib/toplevel/../../share/emacs/site-lisp/inf-caml hides /home/kiwibird/.emacs.d/elpa/caml-20151009.845/inf-caml
/home/kiwibird/.opam/4.02.1/lib/toplevel/../../share/emacs/site-lisp/camldebug hides /home/kiwibird/.emacs.d/elpa/caml-20151009.845/camldebug
/home/kiwibird/.opam/4.02.1/lib/toplevel/../../share/emacs/site-lisp/caml hides /home/kiwibird/.emacs.d/elpa/caml-20151009.845/caml
/home/kiwibird/.opam/4.02.1/lib/toplevel/../../share/emacs/site-lisp/caml-xemacs hides /home/kiwibird/.emacs.d/elpa/caml-20151009.845/caml-xemacs
/home/kiwibird/.opam/4.02.1/lib/toplevel/../../share/emacs/site-lisp/caml-types hides /home/kiwibird/.emacs.d/elpa/caml-20151009.845/caml-types
/home/kiwibird/.opam/4.02.1/lib/toplevel/../../share/emacs/site-lisp/caml-hilit hides /home/kiwibird/.emacs.d/elpa/caml-20151009.845/caml-hilit
/home/kiwibird/.opam/4.02.1/lib/toplevel/../../share/emacs/site-lisp/caml-help hides /home/kiwibird/.emacs.d/elpa/caml-20151009.845/caml-help
/home/kiwibird/.opam/4.02.1/lib/toplevel/../../share/emacs/site-lisp/caml-font hides /home/kiwibird/.emacs.d/elpa/caml-20151009.845/caml-font
/home/kiwibird/.opam/4.02.1/lib/toplevel/../../share/emacs/site-lisp/caml-emacs hides /home/kiwibird/.emacs.d/elpa/caml-20151009.845/caml-emacs
/home/kiwibird/.opam/4.02.1/lib/toplevel/../../share/emacs/site-lisp/caml-compat hides /home/kiwibird/.emacs.d/elpa/caml-20151009.845/caml-compat
/home/kiwibird/.emacs.d/elpa/shorten-20150306.517/shorten hides /home/kiwibird/.emacs.d/elpa/tracking-20151129.319/shorten
/home/kiwibird/.emacs.d/elpa/paredit-20150217.713/paredit hides /home/kiwibird/.emacs.d/lisp/paredit
/home/kiwibird/.emacs.d/elpa/auctex-11.89/tex-site hides /usr/share/emacs/site-lisp/tex-site
/home/kiwibird/.emacs.d/elpa/cmake-mode-20151012.726/cmake-mode hides /usr/share/emacs/site-lisp/cmake-mode
/home/kiwibird/.emacs.d/elpa/auctex-11.89/auctex hides /usr/share/emacs/site-lisp/auctex
/home/kiwibird/.emacs.d/elpa/auctex-11.89/context-en hides /usr/share/emacs/site-lisp/auctex/context-en
/home/kiwibird/.emacs.d/elpa/auctex-11.89/bib-cite hides /usr/share/emacs/site-lisp/auctex/bib-cite
/home/kiwibird/.emacs.d/elpa/auctex-11.89/texmathp hides /usr/share/emacs/site-lisp/auctex/texmathp
/home/kiwibird/.emacs.d/elpa/auctex-11.89/tex-fold hides /usr/share/emacs/site-lisp/auctex/tex-fold
/home/kiwibird/.emacs.d/elpa/auctex-11.89/tex-bar hides /usr/share/emacs/site-lisp/auctex/tex-bar
/home/kiwibird/.emacs.d/elpa/auctex-11.89/tex hides /usr/share/emacs/site-lisp/auctex/tex
/home/kiwibird/.emacs.d/elpa/auctex-11.89/toolbar-x hides /usr/share/emacs/site-lisp/auctex/toolbar-x
/home/kiwibird/.emacs.d/elpa/auctex-11.89/latex hides /usr/share/emacs/site-lisp/auctex/latex
/home/kiwibird/.emacs.d/elpa/auctex-11.89/context-nl hides /usr/share/emacs/site-lisp/auctex/context-nl
/home/kiwibird/.emacs.d/elpa/auctex-11.89/multi-prompt hides /usr/share/emacs/site-lisp/auctex/multi-prompt
/home/kiwibird/.emacs.d/elpa/auctex-11.89/tex-style hides /usr/share/emacs/site-lisp/auctex/tex-style
/home/kiwibird/.emacs.d/elpa/auctex-11.89/font-latex hides /usr/share/emacs/site-lisp/auctex/font-latex
/home/kiwibird/.emacs.d/elpa/auctex-11.89/tex-buf hides /usr/share/emacs/site-lisp/auctex/tex-buf
/home/kiwibird/.emacs.d/elpa/auctex-11.89/tex-mik hides /usr/share/emacs/site-lisp/auctex/tex-mik
/home/kiwibird/.emacs.d/elpa/auctex-11.89/preview hides /usr/share/emacs/site-lisp/auctex/preview
/home/kiwibird/.emacs.d/elpa/auctex-11.89/context hides /usr/share/emacs/site-lisp/auctex/context
/home/kiwibird/.emacs.d/elpa/auctex-11.89/tex-info hides /usr/share/emacs/site-lisp/auctex/tex-info
/home/kiwibird/.emacs.d/elpa/auctex-11.89/prv-emacs hides /usr/share/emacs/site-lisp/auctex/prv-emacs
/home/kiwibird/.emacs.d/elpa/auctex-11.89/tex-font hides /usr/share/emacs/site-lisp/auctex/tex-font
/home/kiwibird/.emacs.d/elpa/auctex-11.89/plain-tex hides /usr/share/emacs/site-lisp/auctex/plain-tex
/home/kiwibird/.emacs.d/elpa/auctex-11.89/tex-jp hides /usr/share/emacs/site-lisp/auctex/tex-jp
/usr/share/emacs/site-lisp/emms/tq hides /usr/share/emacs/24.5/lisp/emacs-lisp/tq

Features:
(shadow emacsbug vc eieio-opt cal-move gnus-dup rainbow-mode
js2-refactor js2r-paredit js2r-conveniences js2r-conditionals
js2r-wrapping js2r-functions js2r-vars js2r-iife js2r-formatting
js2r-helpers flymake-jslint flymake-easy northern-saami-eim
ido-completing-read+ org-clock erc-yank flow-fill tabify image-file
org-capture w3m-form w3m-filter w3m-cookie w3m-bookmark w3m-tabmenu
w3m-session w3m-search kbu-w3m w3m-lnum w3m w3m-hist w3m-fb bookmark-w3m
w3m-ems w3m-ccl ccl w3m-favicon w3m-image w3m-proc w3m-util
rectangular-region-mode multiple-cursors-core evil-ediff nose python
jedi jedi-core python-environment epc ctable concurrent flycheck-ycmd
company-ycmd glasses magit-svn linum magit-blame magit-stash
magit-bisect magit-remote magit-commit magit-sequence magit magit-apply
magit-wip magit-log magit-diff smerge-mode magit-core magit-autorevert
autorevert filenotify magit-process magit-popup magit-mode magit-git
magit-section magit-utils git-commit tempo ispell ess-dde ess-omg-l
ess-toolbar ess-mouse mouseme ess-menu ess-swv ess-noweb essd-els
ess-sas-d ess-sas-l ess-sas-a ess-sta-d ess-sta-l make-regexp ess-sp6-d
ess-sp3-d ess-julia julia-mode ert debug ess-r-d ess-r-syntax
ess-r-completion ess-tracebug ess-roxy hideshow ess-help reporter
ess-developer ess-s-l speedbar sb-image ezimage dframe ess-site ess
ess-mode ess-noweb-mode ess-custom executable ess-inf ess-utils
ess-bugs-l ess-compat ess-lsp-l ffap highlight bookmark cus-edit
cus-start cus-load ycmd quail inf-haskell haskell-decl-scan haskell
haskell-completions haskell-load haskell-commands highlight-uses-mode
haskell-modules haskell-sandbox haskell-repl haskell-debug
haskell-interactive-mode haskell-presentation-mode haskell-collapse
haskell-navigate-imports haskell-compile haskell-process haskell-session
haskell-cabal haskell-utils haskell-hoogle haskell-mode
haskell-font-lock haskell-indentation haskell-string
haskell-sort-imports haskell-lexeme haskell-align-imports haskell-compat
haskell-complete-module dabbrev haskell-customize js2-mode
js2-old-indent js moz cc-mode cc-fonts cc-guess cc-menus cc-cmds
cc-styles cc-align cc-engine cc-vars cc-defs imenu with-editor
async-bytecomp async log-edit pcvs-util add-log sx-inbox sx-interaction
sx-compose sx-question-list sx-favorites sx-question-mode
sx-question-print sx-user sx-babel sx-time sx-switchto sx-networks
sx-site sx-tag markdown-mode sx-button sx-question sx-method sx-auth
sx-filter sx-cache sx-request sx-encoding sx let-alist term ehelp
esh-var esh-io esh-cmd esh-opt esh-ext esh-proc esh-arg esh-groups
eshell esh-module esh-mode esh-util warnings ycmd-request-deferred json
hmac-def f s ucs-normalize deferred ycmd-request ediff-merg ediff-wind
ediff-diff ediff-mult ediff-help ediff-init ediff-util ediff names
edebug autoload tar-mode lisp-mnt url-http url-gw url-auth url-handlers
gnus-html mm-url shr-color color mailalias bbdb-message footnote pabbrev
nnir xterm org-table cal-iso org-rmail org-mhe org-irc org-info org-gnus
org-docview doc-view jka-compr image-mode dired-x dired org-bibtex
bibtex org-bbdb org-w3m org-agenda org-random-todo org-element org-crypt
org org-macro org-footnote org-pcomplete org-list org-faces org-entities
noutline outline org-version ob-emacs-lisp ob ob-tangle ob-ref ob-lob
ob-table ob-exp org-src ob-keys ob-comint ob-core ob-eval org-compat
org-macs org-loaddefs bbdb-vcard vcard qp gnus-gravatar gravatar
url-cache url url-proxy url-privacy url-expand url-methods url-history
url-cookie url-domsuf url-util url-parse url-vars sort gnus-cite smiley
shr browse-url mm-archive gnus-async gnus-bcklg mail-extr gnus-ml
gnus-topic nndraft nnmh gnus-agent gnus-srvr gnus-score score-mode
nnvirtual gnus-msg gnus-art mm-uu mml2015 utf-7 gnus-cache gnus-sum
bbdb-gnus nnimap parse-time utf7 tramp-cache tramp-sh tramp tramp-compat
tramp-loaddefs trampver shell misearch multi-isearch vc-dispatcher
vc-svn hi-lock dix whattf-dt html5-langs nxml-uchnm rng-xsd xsd-regexp
rng-cmpct rng-nxml rng-valid rng-loc rng-uri rng-parse nxml-parse
rng-match rng-dt rng-util rng-pttrn nxml-ns nxml-mode nxml-outln
nxml-rap nxml-util nxml-glyph nxml-enc xmltok kbu-selector view
network-stream bitlbee erc-capab erc-log rot13 disp-table epa-file epa
derived epg netrc kbu-erc erc-track-score erc-autoaway notmuch hl-line
notmuch-message notmuch-maildir-fcc notmuch-hello notmuch-tree
notmuch-parser notmuch-show notmuch-print notmuch-crypto notmuch-mua
notmuch-address notmuch-wash diff-mode coolj notmuch-query goto-addr
icalendar notmuch-tag notmuch-lib notmuch-version mm-view mml-smime
smime dig kbu-bbdb bbdb-anniv bbdb2erc bbdb-mua bbdb-com crm bbdb
bbdb-site timezone gnus-demon nntp gnus-group gnus-undo nnmail
mail-source gnus-start gnus-spec nnoo gnus-int gnus-range offlineimap
smtpmail sendmail message idna rfc822 mml mml-sec mm-decode mm-bodies
mm-encode mail-parse rfc2231 rfc2047 rfc2045 ietf-drums mailabbrev
gmm-utils mailheader gnus-win gnus gnus-ems nnheader mail-utils
sauron-elfeed sauron-identica sauron-jabber jabber jabber-notifications
jabber-libnotify jabber-awesome jabber-osd jabber-wmii jabber-xmessage
jabber-festival jabber-sawfish jabber-ratpoison jabber-tmux
jabber-screen jabber-socks5 jabber-ft-server jabber-si-server
jabber-ft-client jabber-ft-common jabber-si-client jabber-si-common
jabber-feature-neg jabber-truncate jabber-time jabber-autoaway
jabber-vcard-avatars jabber-chatstates jabber-events jabber-vcard
jabber-avatar mailcap jabber-activity jabber-watch jabber-modeline
jabber-ahc-presence jabber-ahc jabber-version jabber-ourversion
jabber-muc-nick-completion hippie-exp jabber-browse jabber-search
jabber-register jabber-roster jabber-presence jabber-muc
jabber-bookmarks jabber-private jabber-muc-nick-coloring hexrgb
jabber-widget jabber-disco jabber-chat jabber-history jabber-chatbuffer
jabber-alert jabber-iq jabber-core jabber-console sgml-mode ewoc
jabber-keymap jabber-sasl sasl sasl-anonymous sasl-login sasl-plain fsm
jabber-logon jabber-conn srv dns starttls tls gnutls jabber-xml
jabber-menu jabber-util sauron-twittering sauron-notifications
notifications sauron-org sauron-dbus dbus xml sauron-erc erc-list
erc-menu erc-join erc-ring erc-networks erc-pcomplete pcomplete
erc-track erc-match erc-button erc-fill erc-stamp erc-netsplit
erc-goodies erc erc-backend erc-compat format-spec auth-source eieio
gnus-util mm-util mail-prsvr password-cache pp sauron aggressive-indent
company-files company-oddmuse company-keywords company-etags
company-gtags company-dabbrev-code company-dabbrev company-capf
company-cmake company-xcode company-clang company-semantic company-eclim
company-template company-css company-nxml company-bbdb company pcase
eldoc flycheck find-func rx subr-x seq flymake compile comint ansi-color
auto-complete popup elisp-slime-nav etags cl-macs evil-surround
smart-mode-line-respectful-theme smart-mode-line mule-util
wheatgrass-theme kbu-dix yasnippet help-mode cl gv w3m-load
smartparens-haskell smartparens dash evil-leader evil evil-integration
undo-tree diff evil-maps evil-commands evil-command-window evil-types
evil-search evil-ex evil-macros evil-repeat evil-states evil-core
evil-common windmove thingatpt rect evil-digraphs evil-vars ring kbu-org
solar cal-dst holidays hol-loaddefs vc-git appt diary-lib diary-loaddefs
ycmd-next-error pulse rich-minority time fasd grizzl
find-file-in-repository recentf tree-widget wid-edit ido byte-opt server
saveplace delsel cua-base cal-menu calendar cal-loaddefs calendar-norway
midnight time-date paren iso-transl whitespace edmacro kmacro
use-package diminish bytecomp byte-compile cl-extra cconv bind-key
easy-mmode cl-loaddefs cl-lib tex-site bbdb2erc-autoloads
color-theme-approximate-autoloads ddg-autoloads
erc-track-score-autoloads finder-inf fiplr-autoloads
flymake-jslint-autoloads flymake-easy-autoloads goto-chg-autoloads
eieio-core htmlize-autoloads epc-autoloads ctable-autoloads
mwe-log-commands-autoloads advice help-fns oauth-autoloads
tea-time-autoloads undo-tree-autoloads info easymenu package epg-config
tooltip electric uniquify ediff-hook vc-hooks lisp-float-type mwheel
x-win x-dnd tool-bar dnd fontset image regexp-opt fringe tabulated-list
newcomment lisp-mode prog-mode register page menu-bar rfn-eshadow timer
select scroll-bar mouse jit-lock font-lock syntax facemenu font-core
frame cham georgian utf-8-lang misc-lang vietnamese tibetan thai
tai-viet lao korean japanese hebrew greek romanian slovak czech european
ethiopic indian cyrillic chinese case-table epa-hook jka-cmpr-hook help
simple abbrev minibuffer nadvice loaddefs button faces cus-face macroexp
files text-properties overlay sha1 md5 base64 format env code-pages mule
custom widget hashtable-print-readable backquote make-network-process
dbusbind gfilenotify dynamic-setting font-render-setting x-toolkit x
multi-tty emacs)

Memory information:
((conses 16 3103039 485040)
 (symbols 48 111250 53)
 (miscs 40 8694 10614)
 (strings 32 559730 73135)
 (string-bytes 1 12056519)
 (vectors 16 127450)
 (vector-slots 8 2574901 123292)
 (floats 8 2651 4773)
 (intervals 56 166205 4219)
 (buffers 960 203)
 (heap 1024 211709 39004))
<#secure method=pgpmime mode=sign>