unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#16634: 24.3.50; extra newline in skeleton {} in sh-mode
@ 2014-02-03 17:53 Sam Steingold
  2014-02-04  3:35 ` Glenn Morris
  0 siblings, 1 reply; 5+ messages in thread
From: Sam Steingold @ 2014-02-03 17:53 UTC (permalink / raw)
  To: 16634

In GNU Emacs 24.3.50.1 (x86_64-apple-darwin13.0.0, NS apple-appkit-1265.00)
 of 2014-02-03 on sds-MacBook-Pro.local
Windowing system distributor `Apple', version 10.3.1265
Configured using:
 `configure --with-ns'

when I type "${" in a middle of a shell script command line, the
matching closing brace "}" is auto-inserted together with a newline
after it, which seems wrong since I am inserting a shell variable value
and not a block.


Important settings:
  value of $LANG: C
  locale-coding-system: utf-8-unix

Major mode: Shell-script

Minor modes in effect:
  sh-electric-here-document-mode: t
  rcirc-track-minor-mode: t
  which-function-mode: t
  url-handler-mode: t
  show-paren-mode: t
  desktop-save-mode: t
  shell-dirtrack-mode: t
  tooltip-mode: t
  electric-indent-mode: t
  mouse-wheel-mode: t
  menu-bar-mode: t
  file-name-shadow-mode: t
  global-font-lock-mode: t
  font-lock-mode: t
  blink-cursor-mode: t
  auto-composition-mode: t
  auto-encryption-mode: t
  auto-compression-mode: t
  column-number-mode: t
  line-number-mode: t

-- 
Sam Steingold (http://sds.podval.org/) on darwin Ns 10.3.1265
http://www.childpsy.net/ http://www.PetitionOnline.com/tap12009/
http://dhimmi.com http://pmw.org.il http://memri.org
UNIX is as friendly to you as you are to it. Windows is hostile no matter what.





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

* bug#16634: 24.3.50; extra newline in skeleton {} in sh-mode
  2014-02-03 17:53 bug#16634: 24.3.50; extra newline in skeleton {} in sh-mode Sam Steingold
@ 2014-02-04  3:35 ` Glenn Morris
  2014-02-04 22:40   ` Sam Steingold
  0 siblings, 1 reply; 5+ messages in thread
From: Glenn Morris @ 2014-02-04  3:35 UTC (permalink / raw)
  To: sds; +Cc: 16634


Recipe from emacs -Q?





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

* bug#16634: 24.3.50; extra newline in skeleton {} in sh-mode
  2014-02-04  3:35 ` Glenn Morris
@ 2014-02-04 22:40   ` Sam Steingold
  2016-12-20  1:39     ` npostavs
  0 siblings, 1 reply; 5+ messages in thread
From: Sam Steingold @ 2014-02-04 22:40 UTC (permalink / raw)
  To: Glenn Morris; +Cc: 16634

> * Glenn Morris <etz@tah.bet> [2014-02-03 22:35:15 -0500]:
>
> Recipe from emacs -Q?

emacs -Q

Eval these:

(define-key global-map "{" 'skeleton-pair-insert-maybe)
(setq skeleton-pair t)

M-x sh-mode RET
insert:

foo bar

put the point between "foo" and " bar" (i.e., before SPC)

hit "{"

result: "{}\n" is inserted, the point is placed between the braces.
expected: "{}" is inserted, the point is placed between the braces.

-- 
Sam Steingold (http://sds.podval.org/) on darwin Ns 10.3.1265
http://www.childpsy.net/ http://pmw.org.il http://americancensorship.org
http://camera.org http://openvotingconsortium.org http://dhimmi.com
My inferiority complex is not as good as yours.





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

* bug#16634: 24.3.50; extra newline in skeleton {} in sh-mode
  2014-02-04 22:40   ` Sam Steingold
@ 2016-12-20  1:39     ` npostavs
  2017-01-01 21:37       ` npostavs
  0 siblings, 1 reply; 5+ messages in thread
From: npostavs @ 2016-12-20  1:39 UTC (permalink / raw)
  To: Sam Steingold; +Cc: 16634

[-- Attachment #1: Type: text/plain, Size: 806 bytes --]

tags 16634 patch
quit

Sam Steingold <sds@gnu.org> writes:
>
> emacs -Q
>
> Eval these:
>
> (define-key global-map "{" 'skeleton-pair-insert-maybe)
> (setq skeleton-pair t)
>
> M-x sh-mode RET
> insert:
>
> foo bar
>
> put the point between "foo" and " bar" (i.e., before SPC)
>
> hit "{"
>
> result: "{}\n" is inserted, the point is placed between the braces.
> expected: "{}" is inserted, the point is placed between the braces.

The problem is that sh-mode sets skeleton-end-hook to a function that
doesn't respect skeleton-end-newline:

  (setq-local skeleton-end-hook
	      (lambda () (or (eolp) (newline) (indent-relative))))

Since skeleton-insert already does

  (or (eolp) (not skeleton-end-newline) (newline-and-indent))

I think the fix is simply to remove sh-mode's custom skeleton-end-hook.


[-- Attachment #2: patch --]
[-- Type: text/plain, Size: 995 bytes --]

From b8810e40da2d68555b294b4d809346db6226b144 Mon Sep 17 00:00:00 2001
From: Noam Postavsky <npostavs@gmail.com>
Date: Mon, 19 Dec 2016 20:16:50 -0500
Subject: [PATCH v1] Remove sh-mode's skeleton-end-hook

* lisp/progmodes/sh-script.el (sh-mode): Remove local setting of
`skeleton-end-hook', `skeleton-insert' already does `newline-and-indent'
and also respects `skeleton-end-newline' (Bug#16634).
---
 lisp/progmodes/sh-script.el | 2 --
 1 file changed, 2 deletions(-)

diff --git a/lisp/progmodes/sh-script.el b/lisp/progmodes/sh-script.el
index 5d362e4..f34b5e6 100644
--- a/lisp/progmodes/sh-script.el
+++ b/lisp/progmodes/sh-script.el
@@ -1629,8 +1629,6 @@ sh-mode
 
   (setq-local skeleton-pair-default-alist
 	      sh-skeleton-pair-default-alist)
-  (setq-local skeleton-end-hook
-	      (lambda () (or (eolp) (newline) (indent-relative))))
 
   (setq-local paragraph-start (concat page-delimiter "\\|$"))
   (setq-local paragraph-separate (concat paragraph-start "\\|#!/"))
-- 
2.9.3


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

* bug#16634: 24.3.50; extra newline in skeleton {} in sh-mode
  2016-12-20  1:39     ` npostavs
@ 2017-01-01 21:37       ` npostavs
  0 siblings, 0 replies; 5+ messages in thread
From: npostavs @ 2017-01-01 21:37 UTC (permalink / raw)
  To: Sam Steingold; +Cc: 16634

tags 16634 fixed
close 16634 26.1
quit

npostavs@users.sourceforge.net writes:
>
> I think the fix is simply to remove sh-mode's custom skeleton-end-hook.
>

Pushed as 5da2a5f449cd, "Remove sh-mode's skeleton-end-hook".





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

end of thread, other threads:[~2017-01-01 21:37 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-02-03 17:53 bug#16634: 24.3.50; extra newline in skeleton {} in sh-mode Sam Steingold
2014-02-04  3:35 ` Glenn Morris
2014-02-04 22:40   ` Sam Steingold
2016-12-20  1:39     ` npostavs
2017-01-01 21:37       ` npostavs

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).