From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Drew Adams Newsgroups: gmane.emacs.help Subject: RE: Frame numbering Date: Sat, 19 Apr 2014 12:42:14 -0700 (PDT) Message-ID: References: <3b67fd8d-7cd3-469b-9975-154fb3b5dfbe@default> 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 1397936584 3731 80.91.229.3 (19 Apr 2014 19:43:04 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sat, 19 Apr 2014 19:43:04 +0000 (UTC) Cc: help-gnu-emacs@gnu.org To: Joshua Studen Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Sat Apr 19 21:42:57 2014 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 1WbbA6-00063m-LI for geh-help-gnu-emacs@m.gmane.org; Sat, 19 Apr 2014 21:42:54 +0200 Original-Received: from localhost ([::1]:43330 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WbbA6-0008FP-9p for geh-help-gnu-emacs@m.gmane.org; Sat, 19 Apr 2014 15:42:54 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:38222) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Wbb9n-0008FK-67 for help-gnu-emacs@gnu.org; Sat, 19 Apr 2014 15:42:43 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Wbb9Z-0003sd-Db for help-gnu-emacs@gnu.org; Sat, 19 Apr 2014 15:42:35 -0400 Original-Received: from userp1040.oracle.com ([156.151.31.81]:32403) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Wbb9Z-0003sP-6I for help-gnu-emacs@gnu.org; Sat, 19 Apr 2014 15:42:21 -0400 Original-Received: from acsinet21.oracle.com (acsinet21.oracle.com [141.146.126.237]) by userp1040.oracle.com (Sentrion-MTA-4.3.2/Sentrion-MTA-4.3.2) with ESMTP id s3JJgIjT015514 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Sat, 19 Apr 2014 19:42:18 GMT Original-Received: from userz7021.oracle.com (userz7021.oracle.com [156.151.31.85]) by acsinet21.oracle.com (8.14.4+Sun/8.14.4) with ESMTP id s3JJgGJs026408 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=FAIL); Sat, 19 Apr 2014 19:42:17 GMT Original-Received: from abhmp0003.oracle.com (abhmp0003.oracle.com [141.146.116.9]) by userz7021.oracle.com (8.14.4+Sun/8.14.4) with ESMTP id s3JJgGjL017566; Sat, 19 Apr 2014 19:42:16 GMT In-Reply-To: X-Priority: 3 X-Mailer: Oracle Beehive Extensions for Outlook 2.0.1.8 (707110) [OL 12.0.6691.5000 (x86)] X-Source-IP: acsinet21.oracle.com [141.146.126.237] X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.4.x-2.6.x [generic] X-Received-From: 156.151.31.81 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:97240 Archived-At: >> 1. `C-x 5 o' cycles among the available frames. This is true even >> if you use Emacs in a terminal (i.e., without a graphic display) - >> see the Emacs manual, node `Non-Window Terminals'. >>=20 >> 2. Command `select-frame-by-name' raises and selects a frame by name, >> providing completion. Again, this works also without a graphic display. >> Frame names in a terminal are simple by default: FN1, FN2, etc. >> Bind the command to a key, e.g., `C-a' as you suggested. Then >> `C-a TAB 3' takes you to frame FN3. > > Number 1 is what I do now, it's just a lot a bit of a slow-down to > have to do it multiple times if I have multiple frames. >=20 > #2 is very close. The ONLY issue is that I use emacs both via GUI > locally and on a remote machine, I do emacs --daemon.=C2=A0 When I leave > the remote session, and come back and create a new Emacs client, > the frame numbers do NOT start back at F1, I need a combination of > your #2 and the suggested M-x set-frame-name. Maybe next emacs, > there will be a way to set a frame name :). FWIW, here is some code that will give you numeric frame names. Together with binding `select-frame-by-name' to a convenient key it should give you much of what you want. You can add `name-frame-numerically' to a hook, such as `after-make-frame-functions', or put it on an idle timer, or whatever. If the selected name does not have a numeric name (1,2,3...) then `name-frame-numerically' renames it and any other frames with non-numeric names. Else it does nothing (including not renaming any other frames). (require 'cl-lib) (defun frame-number (frame) "Return FRAME's number, or nil if its name is not a numeral 1,2,3..." (let ((num (string-to-number (frame-parameter frame 'name)))) (and (wholenump num) (not (zerop num)) num))) (defun name-frame-numerically (&optional frame frames) "Name FRAME (default, selected frame) to a numeral in 1,2,3... If FRAME's name is already such a numeral, do nothing. Else: Rename it to a numeral one greater than the max numeric frame name. Rename any other frames to numerals also." (interactive) (setq frame (or frame (selected-frame)) frames (or frames (list frame))) (let ((onum (frame-number frame)) onums max) (unless onum (dolist (fr (cl-set-difference (frame-list) frames)) (unless (eq fr frame) (name-frame-numerically fr (cons fr frames)))) (setq onums (delq nil (mapcar #'frame-number (frame-list))) max (if onums (apply #'max onums) 0)) (modify-frame-parameters frame `((name ,@(number-to-string (1+ max)))))))) ;; Just in case you want such a command. (defun name-all-frames-numerically (&optional startover) "Rename all frames to numerals in 1,2,3... With optional arg STARTOVER (prefix arg, interactively), rename all starting over from 1. Otherwise, numbering continues from the highest existing frame number." (interactive "P") (when startover (dolist (fr (frame-list)) (modify-frame-parameters fr `((name ,@(format "a%s" (frame-parameter fr 'name))))))) (mapc #'name-frame-numerically (frame-list))) ;; Name frames when they are created. ;; (add-hook 'after-make-frame-functions 'name-frame-numerically)