From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Tassilo Horn Newsgroups: gmane.emacs.help Subject: Re: Defining functions on the fly Date: Tue, 16 Jun 2015 13:12:52 +0200 Message-ID: <87k2v3rjnv.fsf@gnu.org> References: <557E99BE.2060407@easy-emacs.de> <557FBB3C.8060208@easy-emacs.de> <87lhfkjfvr.fsf@gnu.org> <557FEACC.3030101@easy-emacs.de> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Trace: ger.gmane.org 1434453206 20301 80.91.229.3 (16 Jun 2015 11:13:26 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Tue, 16 Jun 2015 11:13:26 +0000 (UTC) Cc: help-gnu-emacs@gnu.org To: Andreas =?utf-8?Q?R=C3=B6hler?= Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Tue Jun 16 13:13:18 2015 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1Z4ont-0003Uc-7L for geh-help-gnu-emacs@m.gmane.org; Tue, 16 Jun 2015 13:13:17 +0200 Original-Received: from localhost ([::1]:39452 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Z4onr-0000HA-U4 for geh-help-gnu-emacs@m.gmane.org; Tue, 16 Jun 2015 07:13:15 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:48589) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Z4onb-0000Gf-43 for help-gnu-emacs@gnu.org; Tue, 16 Jun 2015 07:13:00 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Z4onX-0007E0-HO for help-gnu-emacs@gnu.org; Tue, 16 Jun 2015 07:12:59 -0400 Original-Received: from deliver.uni-koblenz.de ([141.26.64.15]:51798) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Z4onX-0007DY-Ao for help-gnu-emacs@gnu.org; Tue, 16 Jun 2015 07:12:55 -0400 Original-Received: from thinkpad-t440p (dhcp196.uni-koblenz.de [141.26.71.196]) (using TLSv1 with cipher AES128-SHA (128/128 bits)) (No client certificate requested) by deliver.uni-koblenz.de (Postfix) with ESMTPSA id 848A31A832C; Tue, 16 Jun 2015 13:12:52 +0200 (CEST) Mail-Followup-To: Andreas =?utf-8?Q?R=C3=B6hler?= , help-gnu-emacs@gnu.org In-Reply-To: <557FEACC.3030101@easy-emacs.de> ("Andreas \=\?utf-8\?Q\?R\=C3\=B6h\?\= \=\?utf-8\?Q\?ler\=22's\?\= message of "Tue, 16 Jun 2015 11:22:20 +0200") User-Agent: Gnus/5.130014 (Ma Gnus v0.14) Emacs/25.0.50 (gnu/linux) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-Received-From: 141.26.64.15 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:104975 Archived-At: Andreas R=C3=B6hler writes: >> There is: `forward-sexp' and `backward-sexp'. Although the name sexp >> is a bit lisp-specific, sexp-based motion has been implemented for >> more C-like languages, too. For example, it works well for shell >> scripts > > Unfortunatly couldn't experience this. There are several common cases > within shell-script, where calls to navigate sexp would raise an > error. > > That's why language-modes have to implement a couple of most basic things= . See > > http://lists.gnu.org/archive/html/emacs-devel/2015-06/msg00013.html I agree with Stefan and Arthur on this particular issue. > ### > > vorhanden() { > for i in "blah" "blub"; > do > # some comment (note: for compatibility) > if [ ! -x $i ]; then > > ### > > with cursor last line "if", C-M-b jumps to "for", but should end at > "do" No. `do ... done' is no valid expression, i.e., it cannot stand on its own but is only valid together with for, while, until, or repeat. > From "for" -> > > Debugger entered--Lisp error: (scan-error "Containing expression ends > prematurely" 13 13) > signal(scan-error ("Containing expression ends prematurely" 13 13)) > smie-forward-sexp-command(-1) > forward-sexp(-1) > backward-sexp(1) > call-interactively(backward-sexp nil nil) > command-execute(backward-sexp) Indeed, here I'd expect it to move to the beginning of the function definition. > Or take this: > > ### > > if [ $# =3D=3D 0 ]; then > # some comment (note: for compatibility) > set "" `find . -maxdepth 1 -type f -name "*.txt" | sed 's/..\(.*\)/\= 1/'` > > for i in $*; do > # some comment (note: for compatibility) > pass > done > > fi > > ### > > With cursor at third line, "set", expression is not recognised at all, > C-M-f stops at the end of symbol "set" Well, "command arg arg arg" in shell scripts is equivalent to (command arg arg arg) in lisp with the distinction that with the lisp syntax's parentheses you have a choice to move over the complete expression (when point is on the opening paren) or inside it (when point is on the "command"). Because the shell syntax doesn't have delimiters for the funcall or at least the argument list, there's not much you can do. > That's a fakir's mode :) Well, you can extend it quite easily and declaratively by modifying `sh-smie-sh-grammar', and then your improvements are transparently available to anything which uses sexp-based motion. I don't see how you can get the same benefits with tons and tons of special-case functions. Bye, Tassilo