From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 24495 invoked by alias); 28 Dec 2016 18:28:05 -0000 Mailing-List: contact zsh-users-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Users List List-Post: List-Help: X-Seq: 22305 Received: (qmail 23633 invoked from network); 28 Dec 2016 18:28:04 -0000 X-Qmail-Scanner-Diagnostics: from mail-vk0-f53.google.com by f.primenet.com.au (envelope-from , uid 7791) with qmail-scanner-2.11 (clamdscan: 0.99.2/21882. spamassassin: 3.4.1. Clear:RC:0(209.85.213.53):SA:0(-0.0/5.0):. Processed in 1.024166 secs); 28 Dec 2016 18:28:04 -0000 X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-0.0 required=5.0 tests=RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_PASS,T_DKIM_INVALID autolearn=unavailable autolearn_force=no version=3.4.1 X-Envelope-From: schaefer@brasslantern.com X-Qmail-Scanner-Mime-Attachments: | X-Qmail-Scanner-Zip-Files: | Received-SPF: pass (ns1.primenet.com.au: SPF record at _netblocks.google.com designates 209.85.213.53 as permitted sender) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=brasslantern-com.20150623.gappssmtp.com; s=20150623; h=from:message-id:date:in-reply-to:comments:references:to:subject :mime-version; bh=xYWfUfbIO1MptTZJK6fedJ46XthkxLSY3V9q7ajdi2M=; b=BphpkBzC2adsuCw2bw3BBIudOKrd4kzXFiiJWZGEmjFzcHfcclv6fzvroWNlkTvqk2 wsVGo6LITxkFBvp5bKDXqHzXUiwpKX1Gzdr1c7BsZFGBcCorpu2WwsiXd1mKksHbBN1D Hf11+vBr9PiK6dDcdnMWl5j1zGVeBrXSgYSpGBIqCYoA2qfY8ZhKGzbE9aavepg+Zh67 L2lNNKblZHAoo/uO7f5hjSmwqg4ZUYWMOmOgNlrUL12b6y+dk9k1FP8l0RbEg25OZ2S2 wQhPHJVVb6zNE7HK4NmryVUGDen7zgYHvWSeqzMkbyBIz412tnKEU2m6nIKrU6G7ZnJF evvQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:message-id:date:in-reply-to:comments :references:to:subject:mime-version; bh=xYWfUfbIO1MptTZJK6fedJ46XthkxLSY3V9q7ajdi2M=; b=RdsDRT5gWjYmErjaiBgxOw/+nT2j0n48CWRGlJfQpH0NEDTXb+2qeYUn5NX8HabHxA llLF4hguPtuO/S/QhxSrJTaMgdCk9jPNLYl27+g8eqXmgFR4cH/Pa3rQ+t4S3lZ954k4 Al5Dd2NMXsyzlPEW/2TKdQFzSPcvyActtGcGEZPOV418cDkSQR/57KCRpaH38lZXGEQG RM/qVoNZXNZCw59kRKEC0QOTzN6i8VF6dth+We4oOeNJt2OHfqAJ9hpXkc33zibdFKX5 C1pZNFFVwo3xUgFmx6vftVYcBo972wjznZx1JmpV3IX5NZEXCqTCplMVZGnlmAO9JTtW /ReA== X-Gm-Message-State: AIkVDXJn/2zPZzELrlRCRbSUsgfttfddrpYjj0fd+oIKIIOvJT0GW4pQwUjsUAAcjXAsrg== X-Received: by 10.31.213.194 with SMTP id m185mr11741023vkg.110.1482949317786; Wed, 28 Dec 2016 10:21:57 -0800 (PST) From: Bart Schaefer Message-Id: <161228102207.ZM5358@torch.brasslantern.com> Date: Wed, 28 Dec 2016 10:22:07 -0800 In-Reply-To: Comments: In reply to Ray Andrews "Re: append to history entry?" (Dec 28, 9:39am) References: <5288b537-f06a-d18a-60ea-1f962856c80c__41345.3811700039$1482803962$gmane$org@eastlink.ca> <20161227125530.GA4796@fujitsu.shahaf.local2> <161227080022.ZM519@torch.brasslantern.com> <99549001-5744-c36f-a4dc-404071aba08a@eastlink.ca> <161227110954.ZM1153@torch.brasslantern.com> <0a48db86-b41a-283c-8193-e2766aa5d30b@eastlink.ca> <161227155552.ZM2385@torch.brasslantern.com> <161227220458.ZM3240@torch.brasslantern.com> X-Mailer: OpenZMail Classic (0.9.2 24April2005) To: Ray Andrews , zsh-users@zsh.org Subject: Re: append to history entry? MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii On Dec 28, 9:39am, Ray Andrews wrote: } Subject: Re: append to history entry? } } On 27/12/16 10:04 PM, Bart Schaefer wrote: } > You can't get away from thinking about what you mean. } } Indeed not. The difficulty is that what I mean and what zsh thinks I } mean ain't the same. As it has ever been in pretty much all programming languages. } If I could just intercept the command as it goes into history -- } but with each command knowing what belongs to itself when there are } semicolons That's where your confusion is. History is *NOT* command history. It's *command line input* history. History does NOT know what text belongs to what command, and it's not processed at the same level as the parser that figures that out. It's involved with the lexer, which decides how to break things into tokens but does not decide what those tokens mean. History is thus connected more closely to the line editor than to the command execution engine. } Somewhere, in the deepest bowels of the parser, the literal string } exists just before it is sent to history. No, that's completely wrong. The literal string is long gone by the time you get that far down in the parser. When your "com1" function is called, all the expansions and substitutions have long since been done and the original text discarded; "setopt xtrace" and look at the output -- THAT is what exists at the point "com1" runs. In fact by that point the literal command input is *already in* the history, unless you've stopped it somehow e.g. histignorespace. Read up on the "trap" command with the DEBUG pseudo-signal, and the ZSH_DEBUG_CMD variable, which is the closest thing there is to what you are imagining. The zshaddhistory hook is where you get at the literal input string.