Tabela de exibição da janela e conflito da tabela de exibição do buffer no Emacs

4

No Emacs;

Existe uma maneira para que window-display-table e buffer-display-table tenham efeito ao mesmo tempo?

O motivo é que estou usando Pretty-Control-L (do pacote de scripts Emacs Goodies El ) e espaço em branco (de whitespace.el , acho que está na distribuição base do Emacs, mas não tenho certeza).

  • Pretty-Control-L visualiza feeds de formulário ( ^L ) de maneira personalizada, definindo a entrada para C-l na janela local window-display-table .
  • Espaço em branco visualiza espaços, tabulações e novas linhas configurando entradas no buffer-display-table local do buffer. (e também usando a funcionalidade font-lock ).

Isso usa conflitos (ou melhor, o uso de window-display-table e buffer-display-table conflitos), pois, se o window-display-table não for nil , substituirá completamente qualquer buffer-display-table de qualquer buffer exibido nessa janela .

Citação do manual Emacs Lisp :

38.21.2 Active Display Table

Each window can specify a display table, and so can each buffer. When a buffer B is displayed in window W, display uses the display table for window W if it has one; otherwise, the display table for buffer B if it has one; otherwise, the standard display table if any. The display table chosen is called the "active" display table.

[...]

(ênfase de mim)

Então, existe alguma maneira fácil de consolidar isso? Ou é a única maneira de recodificar um deles para usar o mesmo mecanismo que o outro?

Eu estive pensando em escrever uma variante crua pequena (isto é, ainda menor) da visualização de alimentação de formulário compatível com a visualização de espaço em branco que apenas usa algum gancho de carregamento de buffer (ou outro) para inserir uma entrada codificada. para ^L no buffer-display-table . Mas eu gostaria de saber se há alguma alternativa mais simples.

EDIT: Para esclarecer o problema, aqui está um trecho de uma sessão anotada "Interactive Lisp" (ou seja, do *scratch* -buffer). Isso mostra os comandos e sua saída e anotados com os efeitos:

;; Emacs is started with '-q', to not load my init-file(s).

;; First, write some sample text with tabs and line-feeds:

"A tab: and some text
A line-feed:and some text"
;; Make sure that it is a tab on the first line (input by 'C-q TAB')
;; and a line-feed on the second line (input by 'C-q C-l').
;; These probably won't copy properly into Stack Exchange.

;; This shows the spaces as center-dots, tabs as '>>'-glyphs and
;; new-lines as $'s (or perhaps other glyphs, depending on system
;; setup...). All of them fontified to be dimmed out on yellow/beige/white
;; background.
(whitespace-mode t)
t

;; This turns on pretty-control-l mode. The '^L' above will be
;; prettified...  Since this sets the window display table, the glyphs
;; for the spaces/tabs/new-lines will disappear, but the background of
;; spaces/tabs will still be yellow/beige (since that's done with
;; fontification, not display tables).
(pretty-control-l-mode t)
t

;; This turns pretty-control-l mode OFF again. The form-feed will
;; revert to displaying as '^L'. However, the glyphs for the
;; spaces/tabs/new-lines will not re-appear, since this only removes
;; the 'C-l'-entry in the window-display-list, not the entire list.
(pretty-control-l-mode 0)
nil

;; Nil the window-display-table, to verify that is the culprit.  This
;; will re-enable the glyphs defined by whitespace-mode (since they
;; are still in the buffer display-table).
(set-window-display-table nil nil)
nil

;; To round of; this is my Emacs-version:
(emacs-version)
"GNU Emacs 23.4.1 (i686-pc-linux-gnu, GTK+ Version 2.24.12)
 of 2012-09-22 on akateko, modified by Debian"

;;End.
    
por Johan E 19.06.2014 / 23:38

1 resposta

1

Desculpe pelo seu problema. Eu não vejo o problema que você reporta, seguindo sua receita. Talvez a descrição não esteja completa? Eu posso ativar pretty-control-l-mode e whitespace-mode , e o comportamento que vejo para cada um parece normal. Talvez haja alguma configuração personalizada usada para whitespace-style ou algo assim?

De qualquer forma, talvez ajude se você fizer uma alteração como essa para pretty-control-l-mode . Se assim for, deixe-me saber e vou aplicá-lo ao pp-c-l.el . (Para testar, defina a nova opção como nil .)

 (defcustom pp^L-use-window-display-table-flag t
   "Non-nil: use 'window-display-table'; nil: use 'buffer-display-table'."
   :type 'boolean :group 'Pretty-Control-L)

 (define-minor-mode pretty-control-l-mode
     "Toggle pretty display of Control-l ('^L') characters.
 With ARG, turn pretty display of '^L' on if and only if ARG is positive."
   :init-value nil :global t :group 'Pretty-Control-L
   (if pretty-control-l-mode
       (add-hook 'window-configuration-change-hook 'refresh-pretty-control-l)
     (remove-hook 'window-configuration-change-hook 'refresh-pretty-control-l))
   (walk-windows
    (lambda (window)
      (let ((display-table  (if pp^L-use-window-display-table-flag ; <=========
                                (or (window-display-table window)
                                    (make-display-table))
                              (if buffer-display-table
                                  (copy-sequence buffer-display-table)
                                (make-display-table)))))
        (aset display-table ?4 (and pretty-control-l-mode
                                       (pp^L-^L-display-table-entry window)))
        (if pp^L-use-window-display-table-flag                     ; <=========
            (set-window-display-table window display-table)
          (setq buffer-display-table display-table))))
    'no-minibuf
    'visible))

ATUALIZADO para adicionar um tópico de comentário , caso os comentários sejam excluídos em algum momento:

BTW, I wonder if the hierarchy of display tables described in the doc shouldn't perhaps be applied using inheritance of some kind. Seems a bit primitive for one level (e.g. window) to completely shadow a lower level (e.g. buffer). You might consider sending a question about this to M-x report-emacs-bug. – Drew Sep 24 '14 at 16:36

Ping? Could you please let me know if the change above helps? Thx. – Drew Oct 14 '14 at 18:12

I just read this answer (I have not been around this part of the Internet for a while...). I will check this when I get round to it, perhaps in a few days or so. I'll get back with an ‘Answer approved’ (if it works), or comments (otherwise), as appropriate, later. – Johan E Oct 25 '14 at 22:32

I edited the question to add a more fleshed-out recipe for showing the problem. I'd be interested whether you get the same results. --- Also, is there a way to shadow a system installed .el-file with a user-supplied one (I'm really just a “user”, not a lisp-programmer...)? I don't really feel like messing with the files installed by deb-packages. (That's why I did the problem-recipe before testing your answer...) – Johan E Oct 27 '14 at 1:02

Five seconds after I wrote the last comment I realized that I could just paste the code into scratch and C-j-run it to test. (No need to edit any files.) The results: It works a charm! Thank you! (=> Answer accepted) However, I'd still like to know if you get the same results as I from my problem-recipe (before patching the code). – Johan E Oct 27 '14 at 1:09

I just followed your new recipe, and I saw everything you described (so clearly). And then I read the new comment that you just added. Glad to know that things work OK. Thx for your feedback. – Drew Oct 27 '14 at 1:12

    
por 24.09.2014 / 18:31

Tags