emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: sh-here-document-word should be customizable


From: Glenn Morris
Subject: Re: sh-here-document-word should be customizable
Date: Fri, 08 Apr 2005 18:02:41 +0100
User-agent: Gnus (www.gnus.org), GNU Emacs (www.gnu.org/software/emacs/)

Kevin Rodgers wrote:

> Here's a patch...

Whee - you just beat me! :)
Here's my version, FWIW.

***************
*** 557,568 ****
  
  (defvar sh-here-document-word "EOF"
    "Word to delimit here documents.
! If the first character of this string is \"-\", this character will
! be removed from the string when it is used to close the here document.
! This convention is used by the Bash shell, for example, to indicate
! that leading tabs inside the here document should be ignored.
! Note that Emacs currently has no support for indenting inside here
! documents - you must insert literal tabs by hand.")
  
  (defvar sh-test
    '((sh "[  ]" . 3)
--- 557,570 ----
  
  (defvar sh-here-document-word "EOF"
    "Word to delimit here documents.
! Leading whitespace is removed from this string when closing the
! here document.  If the first character is \"-\", this is also
! removed when closing the here document.  Also in this case, the
! body and end of the here document are indented using tabs, to the
! same level as the start of the here document.  This will only
! work correctly if `sh-basic-offset' is a multiple of
! `tab-width'.")
! 
  
  (defvar sh-test
    '((sh "[  ]" . 3)
***************
*** 3511,3528 ****
        (save-excursion
        (backward-char 2)
        (sh-quoted-p))
!       (progn
        (insert sh-here-document-word)
        (or (eolp) (looking-at "[ \t]") (insert ? ))
        (end-of-line 1)
        (while
            (sh-quoted-p)
          (end-of-line 2))
!       (newline)
        (save-excursion
!           (insert ?\n (substring
!                        sh-here-document-word
!                        (if (string-match "^-" sh-here-document-word) 1 
0)))))))
  
  
  ;; various other commands
--- 3513,3531 ----
        (save-excursion
        (backward-char 2)
        (sh-quoted-p))
!       (let ((tabs (if (string-match "\\`-" sh-here-document-word)
!                       (make-string (/ (current-indentation) tab-width) ?\t)
!                     "")))
        (insert sh-here-document-word)
        (or (eolp) (looking-at "[ \t]") (insert ? ))
        (end-of-line 1)
        (while
            (sh-quoted-p)
          (end-of-line 2))
!       (insert ?\n tabs)
        (save-excursion
!           (insert ?\n tabs (replace-regexp-in-string
!                             "\\`-?[ \t]*" "" sh-here-document-word))))))
  
  
  ;; various other commands




reply via email to

[Prev in Thread] Current Thread [Next in Thread]