unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* hi-lock-write-interactive-patterns inserts trailing whitespace
@ 2005-11-21 12:44 Alexander Klimov
  0 siblings, 0 replies; only message in thread
From: Alexander Klimov @ 2005-11-21 12:44 UTC (permalink / raw)


Hi.

I start to use `highlight trailing whitespace' and now it become
irritating that hi-lock-write-interactive-patterns inserts trailing
whitespaces.

The fix is trivial:

================================================================================
*** hi-lock.el~ Mon Nov 21 14:20:33 2005
--- hi-lock.el  Mon Nov 21 14:21:33 2005
***************
*** 469,473 ****
      (mapcar
       (lambda (pattern)
!        (insert (format "%s (%s) %s\n"
                         prefix (prin1-to-string pattern) (or comment-end ""))))
       hi-lock-interactive-patterns)))
--- 469,473 ----
      (mapcar
       (lambda (pattern)
!        (insert (format "%s (%s)%s\n"
                         prefix (prin1-to-string pattern) (or comment-end ""))))
       hi-lock-interactive-patterns)))
================================================================================

It looks like comment-end has a space almost everywhere:

lisp/progmodes/cc-cmds.el:3373:
 (setq comment-start "/* " comment-end " */"))
./lisp/progmodes/ld-script.el:134:
 (set (make-local-variable 'comment-end)   " */")
./lisp/progmodes/modula2.el:159:
 (setq comment-end " *)")
./lisp/progmodes/simula.el:389:
 (setq comment-end " ;")
./lisp/textmodes/sgml-mode.el:440:
 (set (make-local-variable 'comment-end) " -->")

and this is consistent with its definition:

 String to insert to end a new comment

OTOH I found two places where comment-end does not start with a
space:

./lisp/generic-x.el:1501:
  comment-end               "*/"
./lisp/progmodes/pascal.el:381:
 (setq comment-end "}")

I guess it is a good idea to make them consistent: add a space to
generic-x and pascal and state in comment-end's docs that space should
be used if it is what the user wants.

Alternatively, we can fix subj in a more complex way:

===============================================================================
*** hi-lock.el~ Mon Nov 21 14:20:33 2005
--- hi-lock.el  Mon Nov 21 14:28:31 2005
***************
*** 469,474 ****
      (mapcar
       (lambda (pattern)
!        (insert (format "%s (%s) %s\n"
!                        prefix (prin1-to-string pattern) (or comment-end ""))))
       hi-lock-interactive-patterns)))

--- 469,480 ----
      (mapcar
       (lambda (pattern)
!        (insert (format "%s (%s)%s\n"
!                        prefix
!                        (prin1-to-string pattern)
!                        (if (or (equal comment-end "")
!                                (string-match "^[ \t]" comment-end))
!                            comment-end
!                          (concat " " comment-end))
!                        )))
       hi-lock-interactive-patterns)))
===============================================================================

The double space in the beginning is less annoying, but can also be
fixed for consistency:

===============================================================================
*** hi-lock.el~ Mon Nov 21 14:20:33 2005
--- hi-lock.el  Mon Nov 21 14:31:51 2005
***************
*** 462,466 ****
  be found in variable `hi-lock-interactive-patterns'."
    (interactive)
!   (let ((prefix (format "%s %s:" (or comment-start "") "Hi-lock")))
      (when (> (+ (point) (length prefix)) hi-lock-file-patterns-range)
        (beep)
--- 462,466 ----
  be found in variable `hi-lock-interactive-patterns'."
    (interactive)
!   (let ((prefix (format "%s%s:" (or comment-start "") "Hi-lock")))
      (when (> (+ (point) (length prefix)) hi-lock-file-patterns-range)
        (beep)
===============================================================================

-- 
Regards,
ASK

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2005-11-21 12:44 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-11-21 12:44 hi-lock-write-interactive-patterns inserts trailing whitespace Alexander Klimov

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).