all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* printing configuration per file
@ 2021-01-24  1:11 Tomas Hlavaty
  2021-01-25 18:55 ` Michael Heerdegen
  0 siblings, 1 reply; 3+ messages in thread
From: Tomas Hlavaty @ 2021-01-24  1:11 UTC (permalink / raw)
  To: help-gnu-emacs

Hi,

I would like to specify printing configuration per file instead of
globally.

Example: I have a file /foo/a/a.txt and a file /foo/b/b.txt.  When I
open a.txt, the variables ps-font-size, ps-print-header and
ps-print-footer should have specific values.  When I open b.txt, those
variables should have different values.  I do not want to set those
variables globaly.

What are the ways to achieve that?

I tried storing the files in different directories and using
.dir-locals.el but that did not work (did not set the values + I want to
set the values for a specific file, not for all files in the directory
or per mode):

--- .dir-locals.el file
;;; Directory Local Variables
;;; For more information see (info "(emacs) Directory Variables")

((nil . ((ps-font-size . 10)
         (ps-print-header . nil)
         (ps-print-footer . nil))))
--- eof

Ideally, it should also work without having to store the files in
different directories.

It might work like this:

--- a.txt
This is a document to be printed.

Local variables:
ps-font-size: (9 . 11)
End:
--- eof

But the I need to exclude the Local declaration from being printed.  Is
there an existing way (a function) to get the buffer contents without
Local variables section already?  Or do I need to remove the Local
variables configuration from output myself using my own heuristic?

Is there a way to set local variables not per directory like
.dir-locals.el does but per file and still using different file?
E.g. for /foo/a.txt using /foo/a.txt.file-locals.el?

Is there a gui for setting buffer local variables, e.g. something like
customize but writing the values to Local variables section or
.dir-locals.el file?

Is there a way to see buffer local variables?  There is
(buffer-local-variables) but if I evaluate that in the buffer, *Message*
buffer does not contain readable print of that value.  I do not want to
write a program for this.

Thanks,

Tomas



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

* Re: printing configuration per file
  2021-01-24  1:11 printing configuration per file Tomas Hlavaty
@ 2021-01-25 18:55 ` Michael Heerdegen
  2021-01-25 19:00   ` Michael Heerdegen
  0 siblings, 1 reply; 3+ messages in thread
From: Michael Heerdegen @ 2021-01-25 18:55 UTC (permalink / raw)
  To: Tomas Hlavaty; +Cc: help-gnu-emacs

Tomas Hlavaty <tom@logand.com> writes:

> Hi,
>
> I would like to specify printing configuration per file instead of
> globally.
>
> Example: I have a file /foo/a/a.txt and a file /foo/b/b.txt.  When I
> open a.txt, the variables ps-font-size, ps-print-header and
> ps-print-footer should have specific values.  When I open b.txt, those
> variables should have different values.  I do not want to set those
> variables globaly.
>
> What are the ways to achieve that?
>
> I tried storing the files in different directories and using
> .dir-locals.el but that did not work (did not set the values + I want to
> set the values for a specific file, not for all files in the directory
> or per mode):
>
> --- .dir-locals.el file
> ;;; Directory Local Variables
> ;;; For more information see (info "(emacs) Directory Variables")
>
> ((nil . ((ps-font-size . 10)
>          (ps-print-header . nil)
>          (ps-print-footer . nil))))
> --- eof

Does look ok to me.  I guess you need to find out why directory local
variables don't work for you.

Then, one way to achieve what you want could be to use the `eval'
"pseudo" variable and put your settings as `setq-local' calls there.
You can make the settings conditional by testing `buffer-file-name' in
your specified expression.

> Is there a way to set local variables not per directory like
> .dir-locals.el does but per file and still using different file?
> E.g. for /foo/a.txt using /foo/a.txt.file-locals.el?

Not built in AFAIK.  Apart from doing it "by hand" of course, e.g. by
using `find-file-hook' and testing `buffer-file-name'.

> Is there a gui for setting buffer local variables, e.g. something like
> customize but writing the values to Local variables section or
> .dir-locals.el file?

I only know the commands.

> Is there a way to see buffer local variables?  There is
> (buffer-local-variables) but if I evaluate that in the buffer, *Message*
> buffer does not contain readable print of that value.  I do not want to
> write a program for this.

I suggest to use the command `pp-eval-expression', that prints the value
in a separate buffer in a better readable format.


HTH,

Michael.



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

* Re: printing configuration per file
  2021-01-25 18:55 ` Michael Heerdegen
@ 2021-01-25 19:00   ` Michael Heerdegen
  0 siblings, 0 replies; 3+ messages in thread
From: Michael Heerdegen @ 2021-01-25 19:00 UTC (permalink / raw)
  To: Tomas Hlavaty; +Cc: help-gnu-emacs

Michael Heerdegen <michael_heerdegen@web.de> writes:

> > Is there a way to set local variables not per directory like
> > .dir-locals.el does but per file and still using different file?
> > E.g. for /foo/a.txt using /foo/a.txt.file-locals.el?
>
> Not built in AFAIK. [...]

Maybe project.el (which is currently still developed) will support
something like this some day.

Michael.



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

end of thread, other threads:[~2021-01-25 19:00 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-01-24  1:11 printing configuration per file Tomas Hlavaty
2021-01-25 18:55 ` Michael Heerdegen
2021-01-25 19:00   ` Michael Heerdegen

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.