* Considering hi-lock-file-patterns as safe
@ 2016-02-16 15:02 Kaushal Modi
2016-02-17 23:17 ` John Wiegley
0 siblings, 1 reply; 3+ messages in thread
From: Kaushal Modi @ 2016-02-16 15:02 UTC (permalink / raw)
To: Emacs developers
[-- Attachment #1: Type: text/plain, Size: 1526 bytes --]
Hi all,
I like the hi-lock-file-patterns feature in the hi-lock library. The good
thing is that I do not need to write the hi-lock patterns directly in the
files where I need the highlighting. The patterns can reside in the
.dir-locals.el. That way I can get the highlighting I like non-intrusively
especially when I am working on a file with users using editors other than
emacs. Or even if they are using emacs, I don't have to force my
highlighting style on them.
But by default, customizing the hi-lock-file-patterns in .dir-locals.el is
not convenient as it would always ask the user if the pattern is safe or if
they want to save that "safe-state" to custom.el. It becomes annoying if
you tend to change/update that variable a lot.
So I have this in my config:
;; Mark the `hi-lock-file-patterns' variable as safe so that it can be
;; set in `.dir-locals.el' files.
(put 'hi-lock-file-patterns 'safe-local-variable 'identity)
So now I am wondering if this variable can be marked permanently as safe
within the library itself. That way people can customize it in their
.dir-locals.el files without this hack.
Also related, I'd like below as the default value of
hi-lock-file-patterns-policy:
;; Don't ask before highlighting any Hi-Lock: pattern found in a file
;; Below, (lambda (pattern) t) simply always returns `t' regardless of
;; what the `pattern' input is.
(setq hi-lock-file-patterns-policy (lambda (pattern) t))
What are people's thoughts of this?
Thanks.
--
Kaushal Modi
[-- Attachment #2: Type: text/html, Size: 2062 bytes --]
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: Considering hi-lock-file-patterns as safe
2016-02-16 15:02 Considering hi-lock-file-patterns as safe Kaushal Modi
@ 2016-02-17 23:17 ` John Wiegley
2016-02-18 16:38 ` Kaushal Modi
0 siblings, 1 reply; 3+ messages in thread
From: John Wiegley @ 2016-02-17 23:17 UTC (permalink / raw)
To: Kaushal Modi; +Cc: Emacs developers
>>>>> Kaushal Modi <kaushal.modi@gmail.com> writes:
> So now I am wondering if this variable can be marked permanently as safe
> within the library itself. That way people can customize it in their .
> dir-locals.el files without this hack.
Do we have a precedent for doing this elsewhere?
--
John Wiegley GPG fingerprint = 4710 CF98 AF9B 327B B80F
http://newartisans.com 60E1 46C4 BD1A 7AC1 4BA2
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: Considering hi-lock-file-patterns as safe
2016-02-17 23:17 ` John Wiegley
@ 2016-02-18 16:38 ` Kaushal Modi
0 siblings, 0 replies; 3+ messages in thread
From: Kaushal Modi @ 2016-02-18 16:38 UTC (permalink / raw)
To: John Wiegley, Kaushal Modi, Emacs developers, Juri Linkov
[-- Attachment #1: Type: text/plain, Size: 3467 bytes --]
On Wed, Feb 17, 2016 at 6:17 PM, John Wiegley <jwiegley@gmail.com> wrote:
> >>>>> Kaushal Modi <kaushal.modi@gmail.com> writes:
>
> > So now I am wondering if this variable can be marked permanently as safe
> > within the library itself. That way people can customize it in their .
> > dir-locals.el files without this hack.
>
> Do we have a precedent for doing this elsewhere?
I don't see a single occurrence of
(put 'SOME-VAR 'safe-local-variable 'identity)
in the emacs source.
Here is how I set the hi-lock-text-patterns in my .dir-locals.el
((text-mode . ((hi-lock-file-patterns . (;; UVM_WARNING
("^\\s-*\\(UVM_WARNING\\)\\s-+[^:]"
(1 '(:inherit default
:foreground "black"
:background "orange"
:height 1.1)
prepend))
("^\\s-*\\(UVM_WARNING\\s-+:\\s-+[1-9][0-9]*\\)"
(1 '(:inherit default
:foreground "black"
:background "orange"
:box (:line-width 2 :color
"green")
:height 1.1
:weight bold)
prepend))
;; UVM_ERROR
("^\\s-*\\(UVM_ERROR\\)\\s-+[^:]"
(1 '(:inherit default
:foreground "white"
:background "red"
:height 1.1)
prepend))
("^\\s-*\\(UVM_ERROR\\s-+:\\s-+[1-9][0-9]*\\)"
(1 '(:inherit default
:foreground "white"
:background "red"
:box (:line-width 2 :color
"green")
:height 1.1
:weight bold)
prepend)))))))
As I couldn't figure out how to qualify that alist value of
hi-lock-file-patterns, I used 'identity as the qualifier.
But I do see instances of marking variables as safe (just not using
'identity, which understandably is very risky):
24793:(put 'sh-shell 'safe-local-variable 'symbolp)
25436:(put 'sort-fold-case 'safe-local-variable 'booleanp)
25510:(put 'sort-numeric-base 'safe-local-variable 'integerp)
28175:(put 'time-stamp-format 'safe-local-variable 'stringp)
28176:(put 'time-stamp-time-zone 'safe-local-variable 'string-or-null-p)
28177:(put 'time-stamp-line-limit 'safe-local-variable 'integerp)
28178:(put 'time-stamp-start 'safe-local-variable 'stringp)
28179:(put 'time-stamp-end 'safe-local-variable 'stringp)
28180:(put 'time-stamp-inserts-lines 'safe-local-variable 'symbolp)
So the question would be:
- If we were to mark hi-lock-file-patterns as safe in hi-lock.el itself,
what would be a valid qualifier so that I can set its value as shown above
in my .dir-locals.el?
--
Kaushal Modi
[-- Attachment #2: Type: text/html, Size: 5633 bytes --]
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2016-02-18 16:38 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-02-16 15:02 Considering hi-lock-file-patterns as safe Kaushal Modi
2016-02-17 23:17 ` John Wiegley
2016-02-18 16:38 ` Kaushal Modi
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.