From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: "Pascal J. Bourguignon" Newsgroups: gmane.emacs.help Subject: Re: Defining functions on the fly Date: Tue, 16 Jun 2015 11:50:25 +0200 Organization: Informatimago Message-ID: <874mm8ugm6.fsf@kuiper.lan.informatimago.com> References: <557E99BE.2060407@easy-emacs.de> <557FBB3C.8060208@easy-emacs.de> <87lhfkjfvr.fsf@gnu.org> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Trace: ger.gmane.org 1434448544 9594 80.91.229.3 (16 Jun 2015 09:55:44 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Tue, 16 Jun 2015 09:55:44 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Tue Jun 16 11:55:30 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 1Z4naW-000107-FP for geh-help-gnu-emacs@m.gmane.org; Tue, 16 Jun 2015 11:55:24 +0200 Original-Received: from localhost ([::1]:38976 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Z4naQ-00062l-Rj for geh-help-gnu-emacs@m.gmane.org; Tue, 16 Jun 2015 05:55:18 -0400 Original-Path: usenet.stanford.edu!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail Original-Newsgroups: gnu.emacs.help Original-Lines: 97 Original-X-Trace: individual.net SUe8zhh5vKQslpAb75lXHgnRhltUrZ9v2EHj4JWVGXRK8l42bF Cancel-Lock: sha1:MmU4NzJiM2MxYWRiMWJiMDU2YjlmOTIyMDhiOGY1ZDhiYzViNTIxNQ== sha1:7dYZmt4n3nLapNJlClMCP+C+TpA= Face: iVBORw0KGgoAAAANSUhEUgAAADAAAAAwAQMAAABtzGvEAAAABlBMVEUAAAD///+l2Z/dAAAA oElEQVR4nK3OsRHCMAwF0O8YQufUNIQRGIAja9CxSA55AxZgFO4coMgYrEDDQZWPIlNAjwq9 033pbOBPtbXuB6PKNBn5gZkhGa86Z4x2wE67O+06WxGD/HCOGR0deY3f9Ijwwt7rNGNf6Oac l/GuZTF1wFGKiYYHKSFAkjIo1b6sCYS1sVmFhhhahKQssRjRT90ITWUk6vvK3RsPGs+M1RuR mV+hO/VvFAAAAABJRU5ErkJggg== X-Accept-Language: fr, es, en User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3 (gnu/linux) Original-Xref: usenet.stanford.edu gnu.emacs.help:212689 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:104973 Archived-At: Andreas Röhler writes: > Am 16.06.2015 um 09:01 schrieb Tassilo Horn: >> Andreas Röhler writes: >> >>>>> i'm probably misunderstanding you, but does: >>>>> (defun (intern (concat "current-prefix-" foo) ... >>>>> do what you need? >>>> (defalias (intern (concat "current-prefix-" foo) ...) ...) can work, but >>>> not with defun. In any case, some concrete example of what he needs to >>>> do would go a long way. >>>> >>>> >>>> Stefan >>> Currently Emacs provides some scheme to fontify source code and some >>> basic moves: linewise, symbol, word, paragraph, sexp. >>> >>> There is no idea of statement, block/loop or expression and a poor >>> top-level --beginning/end-of-defun. >> 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 > > ### > > 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" > 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) > > There are many more spots in this example to trigger error or > unexpected moves. > > Or take this: > > ### > > if [ $# == 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" > > That's a fakir's mode :) There are hooks to customize those general commands to specific modes! For example, instead of writing: bash-forward-sexp sh-forward-sexp pascal-forward-sexp ada-forward-sexp etc, each mode will just bind a specific forward sexp function to the hook variable: forward-sexp-function, and forward-sexp will call it. -- __Pascal Bourguignon__ http://www.informatimago.com/ “The factory of the future will have only two employees, a man and a dog. The man will be there to feed the dog. The dog will be there to keep the man from touching the equipment.” -- Carl Bass CEO Autodesk