unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#17956: 24.3.92; Calling highlight-regexp non-interactively causes errors from face-name
@ 2014-07-06 14:17 Mat Smiglarski
  2014-07-06 23:38 ` Juri Linkov
  0 siblings, 1 reply; 3+ messages in thread
From: Mat Smiglarski @ 2014-07-06 14:17 UTC (permalink / raw)
  To: 17956

The logic within #'highlight-regexp for selecting a face is based on
previous calls. This is a good feature, however it may be the cause of
an issue where deleting the frame, visiting the same buffer in another
frame, and then calling the highlight-regexp function interactively.

This does not happen on 24.3.1.

To reproduce:

1. Start emacs:
$ emacs -Q
2. Create new frame:
C-x 5 2 <RET>
3. create buffer:
C-x b "bug" <RET>
4. (optional) Insert text:
123
5. Highlight text non-interactively:
M-: (highlight-regexp "1" "hi-green")
6. Kill frame
C-x 5 0 <RET>
7. Visit buffer on initial frame
C-x b "bug" <RET>
8. Highlight-regexp non-interactively, supplying a default argument
M-x highlight-regexp <RET> 2 <RET>

The following error is encountered:
face-name: Wrong type argument: symbolp, "hi-green"

NB: This bug does not occur when the second call to highlight-regexp is 
interactive.

An alternative recipe to reproduce the bug is the following:

A. start emacs with the following script:

$ emacs -Q -l bug-highlight-regexp.el

Where bug-highlight-regexp.el contains the following:

(defun bug-highlight-regexp-non-interactive-then-interactive ()
   "
Calling #'highlight-regexp non-interactively and
supplying a non-nil face parameter causes errors
with interactive calls (to #'highlight-regexp).
"
   (interactive)
   (let ((bug-frame (make-frame))
         (bug-buffer (get-buffer-create "Bug Demo")))
     (select-frame bug-frame)
     (switch-to-buffer bug-buffer)
     ;; The regexp does not have to match, and
     ;; any valid face parameter can be supplied.
     (highlight-regexp "anything" "hi-green")
     (delete-frame bug-frame)
     (with-selected-frame (make-frame)
       (switch-to-buffer bug-buffer)
       (message "Do `M-x highlight-regexp' with any pattern to invoke
   bug\n"))))

B. Do M-x bug-highlight-regexp-non-interactive-then-interactive <RET>

C. Call M-x highlight-regexp

Regards,
Mat


In GNU Emacs 24.3.92.1 (x86_64-unknown-linux-gnu, GTK+ Version 3.10.8)
  of 2014-06-29 on zz
Windowing system distributor `The X.Org Foundation', version 
11.0.11501000
System Description:	Ubuntu 14.04 LTS

Configured using:
  `configure --with-dbus --with-libotf --with-m17n-flt'

Important settings:
   value of $LC_CTYPE: en_US.UTF-8
   value of $LANG: en_US.UTF-8
   value of $XMODIFIERS: @im=ibus
   locale-coding-system: utf-8-unix

Major mode: Fundamental

Minor modes in effect:
   hi-lock-mode: t
   tooltip-mode: t
   electric-indent-mode: t
   mouse-wheel-mode: t
   tool-bar-mode: t
   menu-bar-mode: t
   file-name-shadow-mode: t
   global-font-lock-mode: t
   blink-cursor-mode: t
   auto-composition-mode: t
   auto-encryption-mode: t
   auto-compression-mode: t
   line-number-mode: t
   transient-mark-mode: t

Recent input:
M-x b u g - h i <tab> <return> <switch-frame> <switch-frame>
M-x h i g h l i <tab> r e <tab> <return> a <return>
M-x r e p o r <tab> <return>

Recent messages:
For information about GNU Emacs and the GNU system, type C-h C-a.
Do `M-x highlight-regexp' with any pattern to invoke bug

face-name: Wrong type argument: symbolp, "hi-green"

Load-path shadows:
None found.

Features:
(shadow sort gnus-util mail-extr emacsbug message format-spec rfc822 mml
easymenu mml-sec mm-decode mm-bodies mm-encode mail-parse rfc2231
mailabbrev gmm-utils mailheader sendmail rfc2047 rfc2045 ietf-drums
mm-util help-fns mail-prsvr mail-utils hi-lock time-date 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
gfilenotify dynamic-setting system-font-setting font-render-setting
move-toolbar gtk x-toolkit x multi-tty emacs)

Memory information:
((conses 16 73527 8937)
  (symbols 48 17463 0)
  (miscs 40 45 114)
  (strings 32 9680 4115)
  (string-bytes 1 258474)
  (vectors 16 9839)
  (vector-slots 8 401423 10857)
  (floats 8 74 272)
  (intervals 56 173 4)
  (buffers 960 12)
  (heap 1024 22961 900))






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

* bug#17956: 24.3.92; Calling highlight-regexp non-interactively causes errors from face-name
  2014-07-06 14:17 bug#17956: 24.3.92; Calling highlight-regexp non-interactively causes errors from face-name Mat Smiglarski
@ 2014-07-06 23:38 ` Juri Linkov
  2014-07-08  9:03   ` Juri Linkov
  0 siblings, 1 reply; 3+ messages in thread
From: Juri Linkov @ 2014-07-06 23:38 UTC (permalink / raw)
  To: Mat Smiglarski; +Cc: 17956

> M-: (highlight-regexp "1" "hi-green")
> [...]
> The following error is encountered:
> face-name: Wrong type argument: symbolp, "hi-green"

The reason why `highlight-regexp' fails is because
`face-name' rejects non-symbol faces whereas `facep'
accepts them.  This contradiction might cause similar
bugs in other places that naively expect a face always
to be a symbol.  For instance, grepping for `face-name'
shows such code as in `x-resolve-font-name'

  (or (symbolp face)
      (setq face (face-name face)))

that didn't fail only because was never called with
a non-nil non-symbol `face'.

So it would be safer not to assume that a face can be only a symbol:

=== modified file 'lisp/faces.el'
--- lisp/faces.el	2014-04-30 18:01:36 +0000
+++ lisp/faces.el	2014-07-06 23:38:01 +0000
@@ -359,7 +359,10 @@ (defun make-face-x-resource-internal (fa
 
 (defun face-name (face)
   "Return the name of face FACE."
-  (symbol-name (check-face face)))
+  (check-face face)
+  (if (symbolp face)
+      (symbol-name face)
+    face))
 
 
 (defun face-all-attributes (face &optional frame)
@@ -2731,8 +2734,8 @@ (defun x-resolve-font-name (pattern &opt
 contains wildcards.
 Given optional arguments FACE and FRAME, return a font which is
 also the same size as FACE on FRAME, or fail."
-  (or (symbolp face)
-      (setq face (face-name face)))
+  (when face
+    (setq face (face-name face)))
   (and (eq frame t)
        (setq frame nil))
   (if pattern







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

* bug#17956: 24.3.92; Calling highlight-regexp non-interactively causes errors from face-name
  2014-07-06 23:38 ` Juri Linkov
@ 2014-07-08  9:03   ` Juri Linkov
  0 siblings, 0 replies; 3+ messages in thread
From: Juri Linkov @ 2014-07-08  9:03 UTC (permalink / raw)
  To: Mat Smiglarski; +Cc: 17956-done

Version: 24.3.92

> So it would be safer not to assume that a face can be only a symbol:

This regression is fixed now in the emacs-24 branch.





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

end of thread, other threads:[~2014-07-08  9:03 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-07-06 14:17 bug#17956: 24.3.92; Calling highlight-regexp non-interactively causes errors from face-name Mat Smiglarski
2014-07-06 23:38 ` Juri Linkov
2014-07-08  9:03   ` Juri Linkov

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).