unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: npostavs@users.sourceforge.net
To: Sam Steingold <sds@gnu.org>
Cc: 16634@debbugs.gnu.org
Subject: bug#16634: 24.3.50; extra newline in skeleton {} in sh-mode
Date: Mon, 19 Dec 2016 20:39:21 -0500	[thread overview]
Message-ID: <87k2avbcqe.fsf@users.sourceforge.net> (raw)
In-Reply-To: <m2bnym33jj.fsf@gnu.org> (Sam Steingold's message of "Tue, 04 Feb 2014 17:40:16 -0500")

[-- 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


  reply	other threads:[~2016-12-20  1:39 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 [this message]
2017-01-01 21:37       ` npostavs

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87k2avbcqe.fsf@users.sourceforge.net \
    --to=npostavs@users.sourceforge.net \
    --cc=16634@debbugs.gnu.org \
    --cc=sds@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).