From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: "Chris Moore" Newsgroups: gmane.emacs.devel Subject: Re: shell-resync-dirs changes my cursor position Date: Tue, 11 Sep 2007 12:36:10 +0200 Message-ID: References: <22953.128.165.0.81.1189470963.squirrel@webmail.lanl.gov> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Trace: sea.gmane.org 1189507655 22020 80.91.229.12 (11 Sep 2007 10:47:35 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Tue, 11 Sep 2007 10:47:35 +0000 (UTC) Cc: rms@gnu.org, emacs-devel@gnu.org To: herring@lanl.gov Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Tue Sep 11 20:47:19 2007 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1IVAlS-0007xs-4v for ged-emacs-devel@m.gmane.org; Tue, 11 Sep 2007 20:47:10 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1IV3H9-00037B-DU for ged-emacs-devel@m.gmane.org; Tue, 11 Sep 2007 06:47:23 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1IV3CD-0002IA-GI for emacs-devel@gnu.org; Tue, 11 Sep 2007 06:42:18 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1IV3CB-0002Hn-QO for emacs-devel@gnu.org; Tue, 11 Sep 2007 06:42:16 -0400 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1IV3C9-0002Ha-E2 for emacs-devel@gnu.org; Tue, 11 Sep 2007 06:42:14 -0400 Original-Received: from rv-out-0910.google.com ([209.85.198.188]) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1IV3C8-0003vk-6y for emacs-devel@gnu.org; Tue, 11 Sep 2007 06:42:12 -0400 Original-Received: by rv-out-0910.google.com with SMTP id c27so1198093rvf for ; Tue, 11 Sep 2007 03:36:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=beta; h=domainkey-signature:received:received:message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; bh=QSIfwmTw39TrXjZo5NgrIUfxeu8gWHpT9mFvkxuij4I=; b=i2WeKHUmGHSEnwrMyBdVu2ihyL8qNolAwnNPHtkg+HQ9nLj8NQ92Sc2YN2nDpzM+PgPtmUcHU6Fdp4AKGk/sPZ/l7DYr7RbG13FuIdzz3pfwTKa6EdwAcARiMVgF/iIHPuvczF8bUEOO1i83H2BK8VI6B8D7gCSI9LczNEcKdS4= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=beta; h=received:message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; b=M83igJQN/GwvAshUY51vdrdY839qdcP9aN71KQzZna5hIVJ7CNZVf92SCJwZ0mQlbahM2RvdunF944sVrUXkc0huuiiE9J2PfFtjjCugLhGzeVO8w0yajg+R1NR49edxo9GEdc5dRxwyJl9TsUxzfXs3phQ5MBbdpjIna8yf3hE= Original-Received: by 10.142.234.12 with SMTP id g12mr285835wfh.1189506970555; Tue, 11 Sep 2007 03:36:10 -0700 (PDT) Original-Received: by 10.143.4.2 with HTTP; Tue, 11 Sep 2007 03:36:10 -0700 (PDT) In-Reply-To: <22953.128.165.0.81.1189470963.squirrel@webmail.lanl.gov> Content-Disposition: inline X-Detected-Kernel: Linux 2.6 (newer, 2) X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:78577 Archived-At: On 9/11/07, Davis Herring wrote: > > Is there a clean, simple way of writing it with save-excursion? > > If that way won't work, then there needs to be a comment explaining > > why it won't -- why the extra complexity is needed. > > I didn't think there was, because point needs to be restored to a > different location in the buffer (after more output from the process), but > minimal testing seems to suggest that it works because the original text > is left in the buffer (just with more inserted before it). OP, if you > don't know what we mean, just ask me off-list. It seems to work just fine for every case except when the cursor starts at the same place as the process mark (ie. at the beginning of the command currently being edited, or with no command yet entered). In that case save-excursion leaves the cursor where it started, rather than moving it down past the 'dirs' command and its output. Here's a patch that uses save-excursion and fixes the case where point starts at the process mark. I didn't re-indent the code, so it's easier to see what I changed. Below it I've pasted a uuencoded version of the same patch after reindenting for the added save-excursion. 2007-09-11 Chris Moore * shell.el (shell-resync-dirs): Don't move the cursor relative to the command being edited. *** shell.el 31 Aug 2007 15:25:36 +0200 1.154 --- shell.el 11 Sep 2007 12:27:54 +0200 *************** *** 808,815 **** command again." (interactive) (let* ((proc (get-buffer-process (current-buffer))) ! (pmark (process-mark proc))) ! (goto-char pmark) ;; If the process echoes commands, don't insert a fake command in ;; the buffer or it will appear twice. (unless comint-process-echoes --- 808,817 ---- command again." (interactive) (let* ((proc (get-buffer-process (current-buffer))) ! (pmark (process-mark proc)) ! (started-at-pmark (= (point) (marker-position pmark)))) ! (save-excursion ! (goto-char pmark) ;; If the process echoes commands, don't insert a fake command in ;; the buffer or it will appear twice. (unless comint-process-echoes *************** *** 852,858 **** (setq shell-dirstack (cdr ds) shell-last-dir (car shell-dirstack)) (shell-dirstack-message)) ! (error (message "Couldn't cd"))))))) ;; For your typing convenience: (defalias 'dirs 'shell-resync-dirs) --- 854,861 ---- (setq shell-dirstack (cdr ds) shell-last-dir (car shell-dirstack)) (shell-dirstack-message)) ! (error (message "Couldn't cd")))))) ! (if started-at-pmark (goto-char (marker-position pmark))))) ;; For your typing convenience: (defalias 'dirs 'shell-resync-dirs) Here's a uuencoded version of the same patch, but after reindenting the function: begin 644 shell-keep-cursor-position.txt.gz M'XL("`)NYD8``W-H96QL+6ME97`M8W5RLT`ON3#22"9,DPI)Y?'O.Z1$6X[M MV,D&:$[F<,1YSY?Q>`QNCDI-4+$O,_BKK>%B.OT=9I?7%Y?77[["V93.;#:9 M7?YVPCE?:\]F<(M-KWUQ??'']?2RUSX9;_Z%,UQ-K\ZO+J\@"@`*LUP*78*H MA=23$4D`,JD]6E%X^8AY)U'HQY!EC34%9#5Z?M]6%5H>!.@<9$5K+>HDS_/\ MY!=@D#5+81>0]6H\GL*A4XA/U\8;7LR%A:B6>YV8GV@RUH"7TCHOB@5_:-&^Y*O;T9T>K:-TTO.*K$]SN`'Z42!8 M+*5KE'A).KU5A[KDSENIZQC[;CN'/HKF5]:I8B&YV">9*F+HJ[5[5-]07C^\ M8"2W6.-STQV"+5T(WY\HT&IOHABCO-\N9+,J2+@"N:NB4;U_F]R^RT;)+H5J M/.[),P5X=Y>/\N0.Q&\W1$$P.>OU5L'&GO@QEV3_V5L!&I^4U,$K?*06=M'% MEFIXZJ"AM(:42MVT'BIKEN`:8ZH@:]UDJR5BUB&[)S^?A"V[OIYM6/Y74`>& M5C!D,Q@>O/(TEPHATX8*H8Q9D!E.2>FRT14E$T6!S3KEIO7!M3A4\7XP3_Z- M,8.L1*HZ)A>I+2TNS2/&\#PAFU8CR/R#3(D/5&%@LP M546N/_O@>_<$^@F5TO7M%AV10]7I<)3ZS1$\U6%^0@>$;[N/R>U2AASQ0M"%EFJU M/*AA:RIG-]M%22%2&R:KK%]:#Z]FG[3*J-5'W-TJX7Q0Z=[8_&+XWN8:6=+T MB!I7JPZMI:',>C&,_C:M*@-@BC(LC]B+`"=Q#OXAS1?3$CU>FI!4BI-6AT1= MX/5)Z$BLA)*"^C*8@]/.M$7WHHOH01XA'EG\=0;TF_^?+.[N*2W68TD+A_>J MWQ(.0OD#/7AC7*QGOT0&^\6)1^3X3+8=W:_[8P_>/P_P[T3\8UF_`A'PWQ7LP?PSHCT,]O`OV!W%_%/`3VVB%;<-Q 2/6O[X?BI_S'\!W.1_B`E$``` ` end