Discussion:
What you type is what you get
(too old to reply)
Roderick
2018-09-19 07:32:47 UTC
Permalink
How to get that emacs do not take decisions for the user?

I do not want indentations and tabs that I do not type.
I do not want anything that I do not type, and I want, what
I type. Is that too much to expect from an editor?!

How to disable this annoying thing completely and without new
similar annoying side effects? It seems to be very difficult, if
not imposible. Perhaps the solution is stopping using emacs.

Stand of the thing:

I wasted a lot of time trying to do it. I have the following in .emacs:

(setq-default indent-tabs-mode t)
(electric-indent-mode -1)

And little changes has big side effects. But what I want is very simple
as said.

Any hint?

Thanks
Rodrigo
Ivan Shmakov
2018-09-19 13:58:02 UTC
Permalink
Post by Roderick
How to get that emacs do not take decisions for the user?
By coding it to behave otherwise? To me, that's the whole point
in using a Lisp implementation for an editor.

When I do not need (or want) sophistication and complexity,
I use Vim (in its minimal build.) AFAIK, there're also "simple"
editors that implement the Emacs look and feel. E. g., I've
used Zile for some time, but its UTF-8 support was lacking.
Post by Roderick
I do not want indentations and tabs that I do not type.
Curiously, the convenience of TAB and M-x indent-region was one
of the reasons I choose Emacs back in the day.
Post by Roderick
I do not want anything that I do not type, and I want, what I type.
Is that too much to expect from an editor?!
[...]
Post by Roderick
I wasted a lot of time trying to do it. I have the following in
(setq-default indent-tabs-mode t)
FTR, for ~/.emacs, plain setq should be sufficient.
Post by Roderick
(electric-indent-mode -1)
And little changes has big side effects. But what I want is very
simple as said.
Any hint?
I also use the following, and I guess you may also find
tab-always-indent relevant to your problem. (Alternatively,
you may consider redefining TAB to self-insert-command.)

(global-eldoc-mode -1)
(transient-mark-mode -1)

FWIW, I've posted the barest minimum of customization I consider
necessary to make Emacs usable to news:alt.sources back in June [1].

[1] minemacs 0.3: my minimal (essential) ~/.emacs
URI: news:***@violet.siamics.net
--
FSF associate member #7257 np. Autumn Symphony (4th Chameleon Remix) -- Dees
Javier
2018-09-20 17:57:01 UTC
Permalink
Post by Roderick
How to get that emacs do not take decisions for the user?
I do not want indentations and tabs that I do not type.
I do not want anything that I do not type, and I want, what
I type. Is that too much to expect from an editor?!
How to disable this annoying thing completely and without new
similar annoying side effects? It seems to be very difficult, if
not imposible. Perhaps the solution is stopping using emacs.
(setq-default indent-tabs-mode t)
(electric-indent-mode -1)
There is more than that. (electric-indent-mode -1) disables some
things but not everything.

To avoid things appearing when you type 'cat<<' in sh-mode.

(add-hook 'sh-mode-hook
(lambda () (sh-electric-here-document-mode -1)))

There might be more autyping stuff which I am unaware of.
Post by Roderick
And little changes has big side effects.
For example, it destroys pasting in a terminal.
Roderick
2018-09-20 20:47:10 UTC
Permalink
To avoid things appearing when you type 'cat<<' in sh-mode. [...]
That was only sh mode. I was annoyed by tcl mode. One needs to do
it for every mode.

Emacs is no a "What You Type Is What You Get" Editor.

Rodrigo
Javier
2018-09-21 01:19:13 UTC
Permalink
Post by Roderick
Emacs is no a "What You Type Is What You Get" Editor.
I agree with you. It's impossible to revert to a reliable behavior.

In any case, if your problem is pasting text to a terminal, they
fixed it with bracketed paste (enabled by default) in emacs 25 and
with recent versions of xterm. However, the pasting text problem
remains with other terminals like rxvt.
Javier
2018-09-22 23:53:30 UTC
Permalink
Post by Javier
Post by Roderick
Emacs is no a "What You Type Is What You Get" Editor.
I agree with you. It's impossible to revert to a reliable behavior.
In any case, if your problem is pasting text to a terminal, they
fixed it with bracketed paste (enabled by default) in emacs 25 and
with recent versions of xterm. However, the pasting text problem
remains with other terminals like rxvt.
Also, if you want to inject text programatically into emacs, wrapping
the text between the escape sequences of bracketed paste mode, should
just insert the text without autotyping anything.

http://www.xfree86.org/4.7.0/ctlseqs.html

Bracketed Paste Mode

When bracketed paste mode is set, pasted text is bracketed with
control sequences so that the program can differentiate pasted text
from typed-in text. When bracketed paste mode is set, the program will
receive: ESC [ 200 ~, followed by the pasted text, followed by ESC [
201 ~.
Roderick
2018-09-25 18:05:45 UTC
Permalink
My problem is, for example, that in tcl mode it adds indentation
when I close a bracket in an expression if { }, proc { } { }, etc.

I want to decide where to put indentation and not leave emacs to do it.

Where I put space, it should be space, and where I do not put it,
it should be not. And the same for every symbol I type or do not type.

It is annoying!

Rodrigo
Julian Bradfield
2018-09-25 19:48:24 UTC
Permalink
Post by Roderick
My problem is, for example, that in tcl mode it adds indentation
when I close a bracket in an expression if { }, proc { } { }, etc.
I want to decide where to put indentation and not leave emacs to do it.
Where I put space, it should be space, and where I do not put it,
it should be not. And the same for every symbol I type or do not type.
So why don't you just edit everything in fundamental mode?
If you don't want the fancy things provided by language-specific
modes, don't use them.
Roderick
2018-09-26 07:43:11 UTC
Permalink
Post by Julian Bradfield
So why don't you just edit everything in fundamental mode?
If you don't want the fancy things provided by language-specific
modes, don't use them.
I do that for example when editing TeX.

In Tcl mode I do like syntax colouring and the possibility to
run scripts from the editing buffer.

Rodrigo
Tim Landscheidt
2018-09-26 09:27:23 UTC
Permalink
Post by Roderick
Post by Julian Bradfield
So why don't you just edit everything in fundamental mode?
If you don't want the fancy things provided by language-specific
modes, don't use them.
I do that for example when editing TeX.
In Tcl mode I do like syntax colouring and the possibility to
run scripts from the editing buffer.
Is your indentation for Tcl truly random, or does it just
deviate from Emacs' default? In the latter case, you could
try to customize Emacs to format your source code as you
want it to be.

Tim
Javier
2018-09-26 13:43:01 UTC
Permalink
Post by Roderick
My problem is, for example, that in tcl mode it adds indentation
when I close a bracket in an expression if { }, proc { } { }, etc.
I want to decide where to put indentation and not leave emacs to do it.
zcat /usr/share/emacs/*/lisp/progmodes/tcl.el.gz | grep electric
...
(define-key map "}" 'tcl-electric-brace)
(defun tcl-electric-brace (arg)
...

So you need to add a hook in tcl-mode-hook disabling it.

Or customize ‘tcl-indent-level’, ‘tcl-continued-indent-level’ if you
just want to use fixed ammounts of indentation.
Ivan Shmakov
2018-09-26 14:05:31 UTC
Permalink
Post by Roderick
My problem is, for example, that in tcl mode it adds indentation
when I close a bracket in an expression if { }, proc { } { }, etc.
I want to decide where to put indentation and not leave emacs to do it.
zcat /usr/share/emacs/*/lisp/progmodes/tcl.el.gz | grep electric ...
It's hardly the classic UUoC, but I'd like to point that there's
zgrep(1).
...
(define-key map "}" 'tcl-electric-brace)
(defun tcl-electric-brace (arg)
...
So you need to add a hook in tcl-mode-hook disabling it.
Seconded; tcl-mode.el (as of July's "master") looks quite an
offender when it comes to easy and straightforward ways to
disable auto-whatever behavior. As such, it may make sense to
just rebind the relevant characters to self-insert-command; like
(possibly in eval-after-load):

(define-key tcl-mode-map "{" 'self-insert-command)
(define-key tcl-mode-map "}" 'self-insert-command)
(define-key tcl-mode-map "[" 'self-insert-command)
(define-key tcl-mode-map "]" 'self-insert-command)
(define-key tcl-mode-map ";" 'self-insert-command)
(define-key tcl-mode-map "#" 'self-insert-command)
Or customize ‘tcl-indent-level’, ‘tcl-continued-indent-level’ if you
just want to use fixed amounts of indentation.
(Curiously, my first ever patch accepted into GNU Emacs was one
to tcl-mode.el. I think I haven't used Tcl much since that
time, although I've recently became interested in Jim.)
--
FSF associate member #7257 http://am-1.org/~ivan/
Ralf Fassel
2018-09-26 14:40:40 UTC
Permalink
* Roderick <***@gmail.com>
| My problem is, for example, that in tcl mode it adds indentation
| when I close a bracket in an expression if { }, proc { } { }, etc.
| I want to decide where to put indentation and not leave emacs to do it.
| Where I put space, it should be space, and where I do not put it,
| it should be not. And the same for every symbol I type or do not type.

In your .emacs:

(setq tcl-mode-map (make-sparse-keymap))

disables most of the specialized keys, while keeping syntax highlight
etc. Works for me with GNU emacs 24.3.

HTH
R'
Ivan Shmakov
2018-09-26 15:10:20 UTC
Permalink
Post by Ralf Fassel
Post by Roderick
My problem is, for example, that in tcl mode it adds indentation
when I close a bracket in an expression if { }, proc { } { }, etc.
I want to decide where to put indentation and not leave emacs to do it.
Where I put space, it should be space, and where I do not put it, it
should be not. And the same for every symbol I type or do not type.
(setq tcl-mode-map (make-sparse-keymap))
disables most of the specialized keys, while keeping syntax highlight
etc. Works for me with GNU emacs 24.3.
Unfortunately, that'd also disable the tcl-eval- and similar
bindings, which may or may not be desirable; per July's "master":

(define-key map "\M-\C-x" 'tcl-eval-defun)
(define-key map "\C-c\C-i" 'tcl-help-on-word)
(define-key map "\C-c\C-v" 'tcl-eval-defun)
(define-key map "\C-c\C-f" 'tcl-load-file)
(define-key map "\C-c\C-t" 'inferior-tcl)
(define-key map "\C-c\C-x" 'tcl-eval-region)
(define-key map "\C-c\C-s" 'switch-to-tcl)
--
FSF associate member #7257 http://am-1.org/~ivan/
Roderick
2018-09-26 18:28:36 UTC
Permalink
Post by Ivan Shmakov
Post by Ralf Fassel
(setq tcl-mode-map (make-sparse-keymap))
disables most of the specialized keys, while keeping syntax highlight
etc. Works for me with GNU emacs 24.3.
Unfortunately, that'd also disable the tcl-eval- and similar
Indeed, unfortunately. My mode file is called

share/emacs/25.3/lisp/progmodes/tcl.el

And there is nothing explained about this variable. But in an
old file:

http://web.mit.edu/dosathena/sandbox/emacs-19.28/lisp/tcl-mode.el

we read:

;; You can customise the keybindings either by setting `tcl-prefix-key'
;; or by putting the following in your .emacs
;; (setq tcl-mode-map (make-sparse-keymap))
;; and
;; (define-key tcl-mode-map <your-key> <function>)
;; for all the functions you need.

Why it is not anymore mentioned?

Rodrigo

Ivan Shmakov
2018-09-21 05:15:42 UTC
Permalink
[...]
Post by Javier
There is more than that. (electric-indent-mode -1) disables some
things but not everything.
To avoid things appearing when you type 'cat<<' in sh-mode.
(add-hook 'sh-mode-hook
(lambda () (sh-electric-here-document-mode -1)))
There might be more autyping stuff which I am unaware of.
M-x apropos-command RET electric RET lists some 27 commands on
my Emacs, not all of them modes. It should be a decent starting
point for when Emacs starts adding text on its own.
Post by Javier
Post by Roderick
And little changes has big side effects.
For example, it destroys pasting in a terminal.
I just use a temporary (fundamental-mode) buffer; e. g.,
C-x b *x* RET and paste text here; then C-x b RET to go back to
the target buffer and M-x insert-buffer to copy the text there.
--
FSF associate member #7257 http://am-1.org/~ivan/
Javier
2018-09-22 14:04:46 UTC
Permalink
Post by Ivan Shmakov
Post by Javier
To avoid things appearing when you type 'cat<<' in sh-mode.
(add-hook 'sh-mode-hook
(lambda () (sh-electric-here-document-mode -1)))
There might be more autyping stuff which I am unaware of.
M-x apropos-command RET electric RET lists some 27 commands on
my Emacs, not all of them modes. It should be a decent starting
point for when Emacs starts adding text on its own.
That doesn't tell you everything. It lists 20 commands on emacs 26.1,
but sh-electric-here-document-mode is not in the list.

Looking at the NEWS files lists 44 electric things in emacs 26.1.
And then you have things that don't contain the word 'electric',
like `indent-tabs-mode'.

And the NEWS files say that the feature is there, but they
don't say explicitly when it is switched on by default.

find /usr/share/emacs/26.1/etc/NEWS* | xargs grep -i sh-electric-here-document-mode
/usr/share/emacs/26.1/etc/NEWS.24:*** `sh-electric-here-document-mode' now controls auto-insertion of here-docs.


find /usr/share/emacs/26.1/etc/NEWS* | xargs grep -i electric- | \
sed 's/ /\n/g' | grep -- - | sed "s/[\`\'.,;]//g" | \
sed 's/^.*NEWS.*://' | grep -i electric | sort | uniq

after-electric-buffer-menu
c-electric-brace
c-electric-colon
c-electric-delete
c-electric-paren)
c-electric-pound
c-electric-pound-behavior
c-electric-semi&comma
c-toggle-electric-mode
electric-buffer-list
Electric-Buffer-menu
electric-buffer-menu-mode-hook
electric-c-brace
electric-command-history
electric-c-semi
electric-c-sharp-sign
electric-c-terminator
electric-help-shrink-window
electric-indent-chars
electric-indent-functions
electric-indent-local-mode
electric-indent-mode
electric-layout-mode
electric-layout-rules
electric-pair-delete-adjacent-pairs
electric-pair-inhibit-predicate
electric-pair-local-mode
electric-pair-mode
electric-pair-open-newline-between-pairs
electric-pair-preserve-balance
electric-pair-skip-self
electric-pair-skip-whitespace
electric-pair-skip-whitespace-chars
electric-pair-text-pairs
electric-pair-text-syntax-table
electric-quote-chars
electric-quote-context-sensitive
electric-quote-inhibit-functions
electric-quote-mode
latex-electric-env-pair-mode
minibuffer-electric-default-mode
ruby-electric-brace
sgml-electric-tag-pair-mode
sh-electric-here-document-mode
Ivan Shmakov
2018-09-22 15:15:53 UTC
Permalink
Post by Javier
Post by Javier
To avoid things appearing when you type 'cat<<' in sh-mode.
(add-hook 'sh-mode-hook
(lambda () (sh-electric-here-document-mode -1)))
There might be more autyping stuff which I am unaware of.
M-x apropos-command RET electric RET lists some 27 commands on my
Emacs, not all of them modes. It should be a decent starting point
for when Emacs starts adding text on its own.
That doesn't tell you everything. It lists 20 commands on emacs
26.1, but sh-electric-here-document-mode is not in the list.
It is, in my 25.1.1 debian 4+deb9u1:

sh-electric-here-document-mode M-x ... RET
Make << insert a here document skeleton.

Of course, the command has to be either already loaded, or
set up for autoloading.
Post by Javier
Looking at the NEWS files lists 44 electric things in emacs 26.1.
And then you have things that don't contain the word 'electric',
like 'indent-tabs-mode'.
Yes.
Post by Javier
AND the NEWS files say that the feature is there, but they don't say
explicitly when it is switched on by default.
They should, IMO. But it's easy enough to check either way.
Post by Javier
find /usr/share/emacs/26.1/etc/NEWS* | xargs grep -i sh-electric-here-document-mode
Curiously, is there any specific reason /not/ to use -exec?
FWIW, xargs(1) does its own "quoting issues" (unless run with -0.)

$ find /usr/share/emacs/26.1/etc/NEWS* \
-exec grep -i sh-electric-here-document-mode {} +

[...]
--
FSF associate member #7257 np. Out Run: Splash Wave -- Johan Andersson
Javier
2018-09-22 17:09:47 UTC
Permalink
Post by Ivan Shmakov
sh-electric-here-document-mode M-x ... RET
Make << insert a here document skeleton.
Of course, the command has to be either already loaded, or
set up for autoloading.
Exactly, sh-electric-here-document-mode is not loaded until you enter sh-mode
Post by Ivan Shmakov
Post by Javier
find /usr/share/emacs/26.1/etc/NEWS* | xargs grep -i sh-electric-here-document-mode
Curiously, is there any specific reason /not/ to use -exec?
FWIW, xargs(1) does its own "quoting issues" (unless run with -0.)
$ find /usr/share/emacs/26.1/etc/NEWS* \
-exec grep -i sh-electric-here-document-mode {} +
[...]
find -exec is also fine, it's just that I don't remember all find
quirks and I need to check the manpage. For files in a linux system
plain xargs works fine 99% of the time.

On quoting issues, I normally assume that people who make the software
don't name files with spaces or problematic characters. It's truth
that sometimes it's assuming too much and you can find things like

'/usr/lib/python2.7/site-packages/setuptools/script (dev).tmpl'

Yes, for those cases 'find -exec' is better.
Loading...