* sh-here-document-word should be customizable @ 2005-04-07 17:09 Ted Zlatanov 2005-04-07 21:31 ` Kevin Rodgers 2005-04-08 3:22 ` Richard Stallman 0 siblings, 2 replies; 8+ messages in thread From: Ted Zlatanov @ 2005-04-07 17:09 UTC (permalink / raw) I wonder why sh-here-document-word is defined with a defvar instead of a defcustom in progmodes/sh-script.el. It should be customizable from the default value of "EOF," I think. Is it too esoteric for most users? Ted ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: sh-here-document-word should be customizable 2005-04-07 17:09 sh-here-document-word should be customizable Ted Zlatanov @ 2005-04-07 21:31 ` Kevin Rodgers 2005-04-08 16:13 ` Kevin Rodgers 2005-05-02 16:33 ` Daniel Brockman 2005-04-08 3:22 ` Richard Stallman 1 sibling, 2 replies; 8+ messages in thread From: Kevin Rodgers @ 2005-04-07 21:31 UTC (permalink / raw) Ted Zlatanov wrote: > I wonder why sh-here-document-word is defined with a defvar instead of > a defcustom in progmodes/sh-script.el. It should be customizable from > the default value of "EOF," I think. Is it too esoteric for most users? I don't know about most users, but I find it annoying that: 1. The "EOF\n\nEOF" string is inserted and point is moved between the newlines, as soon as I type "<<". I almost always use the "<<-" syntax, so that I can indent the here document between the command and terminating word by tabs for readability. Could sh-maybe-here-document be enhanced to wait (say 1 second) for a `-' input event before inserting the template, and then insert a tab before point if it sees the `-'? 2. I prefer a space after redirection operators, but putting a space at the beginning of sh-here-document-word doesn't produce a valid shell command, because the same space is inserted by sh-maybe-here-document. (The shell only ignores leading tabs -- not spaces -- before the word, and only if the "<<-" syntax is used.) 3. For command foo, I like to use _foo for the terminating word. But sh-here-document-word is static, not dynamic. Thanks, -- Kevin ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: sh-here-document-word should be customizable 2005-04-07 21:31 ` Kevin Rodgers @ 2005-04-08 16:13 ` Kevin Rodgers 2005-04-08 17:02 ` Glenn Morris 2005-05-02 16:33 ` Daniel Brockman 1 sibling, 1 reply; 8+ messages in thread From: Kevin Rodgers @ 2005-04-08 16:13 UTC (permalink / raw) Thanks,> I don't know about most users, but I find it annoying that: > > 1. The "EOF\n\nEOF" string is inserted and point is moved between the > newlines, as soon as I type "<<". I almost always use the "<<-" > syntax, so that I can indent the here document between the command > and terminating word by tabs for readability. Could > sh-maybe-here-document be enhanced to wait (say 1 second) for a `-' > input event before inserting the template, and then insert a tab > before point if it sees the `-'? > > 2. I prefer a space after redirection operators, but putting a space at > the beginning of sh-here-document-word doesn't produce a valid shell > command, because the same space is inserted by > sh-maybe-here-document. (The shell only ignores leading tabs -- not > spaces -- before the word, and only if the "<<-" syntax is used.) Here's a patch that implements (1) as described and addresses (2) by inserting a space after the redirection operator if there is a space before it. It's simpler to combine them in this single patch, but it's easy to identify which bits of code are for each feature if you don't want both: (1) uses next-command-event and (2) uses redirection-point. The patch also makes ARG optional and binds it via the p interactive code, according to convention. *** emacs-21.3/lisp/progmodes/sh-script.el~ Tue Oct 22 02:14:34 2002 --- emacs-21.3/lisp/progmodes/sh-script.el Thu Apr 7 18:03:56 2005 *************** *** 3449,3465 **** ! (defun sh-maybe-here-document (arg) "Insert self. Without prefix, following unquoted `<' inserts here document. The document is bounded by `sh-here-document-word'." ! (interactive "*P") ! (self-insert-command (prefix-numeric-value arg)) ! (or arg (not (eq (char-after (- (point) 2)) last-command-char)) (save-excursion (backward-char 2) (sh-quoted-p)) ! (progn (insert sh-here-document-word) (or (eolp) (looking-at "[ \t]") (insert ? )) (end-of-line 1) --- 3449,3472 ---- ! (defun sh-maybe-here-document (&optional arg) "Insert self. Without prefix, following unquoted `<' inserts here document. + Unquoted `-' quickly following `<<' indents here document with tab character. The document is bounded by `sh-here-document-word'." ! (interactive "*p") ! (self-insert-command arg) ! (or current-prefix-arg (not (eq (char-after (- (point) 2)) last-command-char)) (save-excursion (backward-char 2) (sh-quoted-p)) ! (let ((next-command-event (if (not (sit-for 1 nil t)) ! (read-event))) ! (redirection-point (- (point) 2))) ! (when (equal next-command-event ?-) ! (insert ?-)) ! (when (equal (char-before redirection-point) ? ) ! (insert ? )) (insert sh-here-document-word) (or (eolp) (looking-at "[ \t]") (insert ? )) (end-of-line 1) *************** *** 3467,3472 **** --- 3474,3484 ---- (sh-quoted-p) (end-of-line 2)) (newline) + (cond ((equal next-command-event ?-) + (insert ?\t)) + (next-command-event + (setq unread-command-events + (cons next-command-event unread-command-events)))) (save-excursion (insert ?\n sh-here-document-word))))) \f -- Kevin Rodgers ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: sh-here-document-word should be customizable 2005-04-08 16:13 ` Kevin Rodgers @ 2005-04-08 17:02 ` Glenn Morris 0 siblings, 0 replies; 8+ messages in thread From: Glenn Morris @ 2005-04-08 17:02 UTC (permalink / raw) Cc: emacs-devel 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))))))) \f ;; 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)))))) \f ;; various other commands ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: sh-here-document-word should be customizable 2005-04-07 21:31 ` Kevin Rodgers 2005-04-08 16:13 ` Kevin Rodgers @ 2005-05-02 16:33 ` Daniel Brockman 1 sibling, 0 replies; 8+ messages in thread From: Daniel Brockman @ 2005-05-02 16:33 UTC (permalink / raw) Kevin Rodgers <ihs_4664@yahoo.com> writes: > I don't know about most users, but I find it annoying that: > > 1. The "EOF\n\nEOF" string is inserted and point is moved between the > newlines, as soon as I type "<<". I almost always use the "<<-" > syntax, so that I can indent the here document between the command > and terminating word by tabs for readability. Could > sh-maybe-here-document be enhanced to wait (say 1 second) for a `-' > input event before inserting the template, and then insert a tab > before point if it sees the `-'? The auto-insert behavior is extremely irritating when you are trying to use the <<< syntax (as implemented by bash). I think it should be possible to turn the feature off. -- Daniel Brockman <daniel@brockman.se> ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: sh-here-document-word should be customizable 2005-04-07 17:09 sh-here-document-word should be customizable Ted Zlatanov 2005-04-07 21:31 ` Kevin Rodgers @ 2005-04-08 3:22 ` Richard Stallman 2005-04-11 17:30 ` Ted Zlatanov 1 sibling, 1 reply; 8+ messages in thread From: Richard Stallman @ 2005-04-08 3:22 UTC (permalink / raw) Cc: emacs-devel I wonder why sh-here-document-word is defined with a defvar instead of a defcustom in progmodes/sh-script.el. It should be customizable from the default value of "EOF," I think. I don't see any normal reason to change it, so I see no reason to make it customizable. ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: sh-here-document-word should be customizable 2005-04-08 3:22 ` Richard Stallman @ 2005-04-11 17:30 ` Ted Zlatanov 2005-04-13 18:56 ` Glenn Morris 0 siblings, 1 reply; 8+ messages in thread From: Ted Zlatanov @ 2005-04-11 17:30 UTC (permalink / raw) On Thu, 07 Apr 2005, rms@gnu.org wrote: > I wonder why sh-here-document-word is defined with a defvar instead > of a defcustom in progmodes/sh-script.el. It should be customizable > from the default value of "EOF," I think. > > I don't see any normal reason to change it, > so I see no reason to make it customizable. Well, to customize it, like any other aspect of Emacs, implies a measure of personal choice that's not always required. I find "EOF" boring, personally, so I like to change it. The change would not affect any existing code, it's just a defcustom instead of a defvar. I can set it manually, of course, so I don't require it for myself. I just thought others might like to customize it as well to make sh-mode a little more fun. Ted ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: sh-here-document-word should be customizable 2005-04-11 17:30 ` Ted Zlatanov @ 2005-04-13 18:56 ` Glenn Morris 0 siblings, 0 replies; 8+ messages in thread From: Glenn Morris @ 2005-04-13 18:56 UTC (permalink / raw) Cc: emacs-devel Ted Zlatanov wrote: > On Thu, 07 Apr 2005, rms@gnu.org wrote: > >> I wonder why sh-here-document-word is defined with a defvar instead >> of a defcustom in progmodes/sh-script.el. It should be customizable >> from the default value of "EOF," I think. It's a defcustom now (after an okay from RMS off-list). ^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2005-05-02 16:33 UTC | newest] Thread overview: 8+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2005-04-07 17:09 sh-here-document-word should be customizable Ted Zlatanov 2005-04-07 21:31 ` Kevin Rodgers 2005-04-08 16:13 ` Kevin Rodgers 2005-04-08 17:02 ` Glenn Morris 2005-05-02 16:33 ` Daniel Brockman 2005-04-08 3:22 ` Richard Stallman 2005-04-11 17:30 ` Ted Zlatanov 2005-04-13 18:56 ` Glenn Morris
Code repositories for project(s) associated with this external index https://git.savannah.gnu.org/cgit/emacs.git https://git.savannah.gnu.org/cgit/emacs/org-mode.git This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.