0

I have the following local variables defined in a XeTeX file. As you can see, the input method is currently set to Devanagari. This is inconvenient when I want to type Roman letters. I'd like a way to disable that particular setting so I can then type Roman letters, and then re-enable it. I realise I can change the setting in Emacs, but it would be convenient if I could do so by commenting and uncommenting the file.

%%% Local Variables:
%%% coding: utf-8
%%% mode: latex
%%% eval: (set-input-method 'devanagari-itrans)
%%% TeX-engine: xetex
%%% TeX-master: t
%%% End:

The question How comment out a variable line in a local variable list is related, but doesn't have an answer.

EDIT: I see that the question has been closed as a dupe of this question. I think the the two options provided in the question as at best workarounds. The first one doesn't even attempt to answer the question. The answer even says:

I'm reasonably sure that you can't.

I was hoping there were some other options, at least for my use case - which isn't exactly the same as the other question.

phils
  • 48,657
  • 3
  • 76
  • 115
Faheem Mitha
  • 406
  • 4
  • 16
  • The duplicate question *does* have an answer, which provides two alternatives. – phils Nov 18 '19 at 20:28
  • 1
    Possible duplicate of [How comment out a variable line in a local variable list](https://emacs.stackexchange.com/questions/15253/how-comment-out-a-variable-line-in-a-local-variable-list) – phils Nov 18 '19 at 20:28
  • "...doesn't even attempt to answer the question. The answer even says: I'm reasonably sure that you can't." -- which is an entirely valid answer to a question asking how to do something which can't be done. I'm honestly not sure what more you're expecting from an answer to such a question. (I mean, I realise you're hoping that the answer is wrong and that it *can* be done; but I don't understand how you're coming away with "doesn't even attempt to answer the question" as an impression.) – phils Nov 19 '19 at 04:34
  • @phils Ok, fine. I'm hoping that the answer is wrong about it being impossible, or there is another approach to the question I'm asking - which isn't exactly the same as that question. That question has nothing to do with input method. – Faheem Mitha Nov 19 '19 at 12:07
  • I still think your question generalises to "how can I disable a file-local variable?", which is a duplicate. *Which* variable you are wanting to disable seems largely inconsequential (Stefan's point notwithstanding). If you take another look at my answer to the earlier question, this did cause me to add some further elaboration to one of the workarounds which you might find useful. – phils Nov 19 '19 at 20:21
  • Regarding whether it's *possible*, AFAICS `hack-local-variables` inspects the `Local Variables:` line, extracts the prefix and suffix from that line, then removes those *precise* prefix and suffix strings from each of the variable declarations before processing each one (and signalling an error if it doesn't look right). I don't see any provision in the existing code for skipping declarations. – phils Nov 19 '19 at 20:31
  • `before-hack-local-variables-hook` allows you to manipulate `file-local-variables-alist` before it is processed; but that would be a very different approach, and not so easy to apply on a per-file basis. – phils Nov 19 '19 at 20:31

1 Answers1

2

I don't understand why you want to comment out that line (especially since it won't have any effect until you re-open the file or do something like M-x normal-mode): to toggle the devanagari-itrans input method you can simply use C-\.

Stefan
  • 26,154
  • 3
  • 46
  • 84