pax_global_header00006660000000000000000000000064133264031310014506gustar00rootroot0000000000000052 comment=82bbda31cbe8ef367dd6501c3aa14b7f2c835910 tabbar-2.2/000077500000000000000000000000001332640313100126045ustar00rootroot00000000000000tabbar-2.2/LICENSE000066400000000000000000001045151332640313100136170ustar00rootroot00000000000000 GNU GENERAL PUBLIC LICENSE Version 3, 29 June 2007 Copyright (C) 2007 Free Software Foundation, Inc. Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Preamble The GNU General Public License is a free, copyleft license for software and other kinds of works. The licenses for most software and other practical works are designed to take away your freedom to share and change the works. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change all versions of a program--to make sure it remains free software for all its users. We, the Free Software Foundation, use the GNU General Public License for most of our software; it applies also to any other work released this way by its authors. You can apply it to your programs, too. When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for them if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs, and that you know you can do these things. To protect your rights, we need to prevent others from denying you these rights or asking you to surrender the rights. Therefore, you have certain responsibilities if you distribute copies of the software, or if you modify it: responsibilities to respect the freedom of others. For example, if you distribute copies of such a program, whether gratis or for a fee, you must pass on to the recipients the same freedoms that you received. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights. Developers that use the GNU GPL protect your rights with two steps: (1) assert copyright on the software, and (2) offer you this License giving you legal permission to copy, distribute and/or modify it. For the developers' and authors' protection, the GPL clearly explains that there is no warranty for this free software. For both users' and authors' sake, the GPL requires that modified versions be marked as changed, so that their problems will not be attributed erroneously to authors of previous versions. Some devices are designed to deny users access to install or run modified versions of the software inside them, although the manufacturer can do so. This is fundamentally incompatible with the aim of protecting users' freedom to change the software. The systematic pattern of such abuse occurs in the area of products for individuals to use, which is precisely where it is most unacceptable. Therefore, we have designed this version of the GPL to prohibit the practice for those products. If such problems arise substantially in other domains, we stand ready to extend this provision to those domains in future versions of the GPL, as needed to protect the freedom of users. Finally, every program is threatened constantly by software patents. States should not allow patents to restrict development and use of software on general-purpose computers, but in those that do, we wish to avoid the special danger that patents applied to a free program could make it effectively proprietary. To prevent this, the GPL assures that patents cannot be used to render the program non-free. The precise terms and conditions for copying, distribution and modification follow. TERMS AND CONDITIONS 0. Definitions. "This License" refers to version 3 of the GNU General Public License. "Copyright" also means copyright-like laws that apply to other kinds of works, such as semiconductor masks. "The Program" refers to any copyrightable work licensed under this License. Each licensee is addressed as "you". "Licensees" and "recipients" may be individuals or organizations. To "modify" a work means to copy from or adapt all or part of the work in a fashion requiring copyright permission, other than the making of an exact copy. The resulting work is called a "modified version" of the earlier work or a work "based on" the earlier work. A "covered work" means either the unmodified Program or a work based on the Program. To "propagate" a work means to do anything with it that, without permission, would make you directly or secondarily liable for infringement under applicable copyright law, except executing it on a computer or modifying a private copy. Propagation includes copying, distribution (with or without modification), making available to the public, and in some countries other activities as well. To "convey" a work means any kind of propagation that enables other parties to make or receive copies. Mere interaction with a user through a computer network, with no transfer of a copy, is not conveying. An interactive user interface displays "Appropriate Legal Notices" to the extent that it includes a convenient and prominently visible feature that (1) displays an appropriate copyright notice, and (2) tells the user that there is no warranty for the work (except to the extent that warranties are provided), that licensees may convey the work under this License, and how to view a copy of this License. If the interface presents a list of user commands or options, such as a menu, a prominent item in the list meets this criterion. 1. Source Code. The "source code" for a work means the preferred form of the work for making modifications to it. "Object code" means any non-source form of a work. A "Standard Interface" means an interface that either is an official standard defined by a recognized standards body, or, in the case of interfaces specified for a particular programming language, one that is widely used among developers working in that language. The "System Libraries" of an executable work include anything, other than the work as a whole, that (a) is included in the normal form of packaging a Major Component, but which is not part of that Major Component, and (b) serves only to enable use of the work with that Major Component, or to implement a Standard Interface for which an implementation is available to the public in source code form. A "Major Component", in this context, means a major essential component (kernel, window system, and so on) of the specific operating system (if any) on which the executable work runs, or a compiler used to produce the work, or an object code interpreter used to run it. The "Corresponding Source" for a work in object code form means all the source code needed to generate, install, and (for an executable work) run the object code and to modify the work, including scripts to control those activities. However, it does not include the work's System Libraries, or general-purpose tools or generally available free programs which are used unmodified in performing those activities but which are not part of the work. For example, Corresponding Source includes interface definition files associated with source files for the work, and the source code for shared libraries and dynamically linked subprograms that the work is specifically designed to require, such as by intimate data communication or control flow between those subprograms and other parts of the work. The Corresponding Source need not include anything that users can regenerate automatically from other parts of the Corresponding Source. The Corresponding Source for a work in source code form is that same work. 2. Basic Permissions. All rights granted under this License are granted for the term of copyright on the Program, and are irrevocable provided the stated conditions are met. This License explicitly affirms your unlimited permission to run the unmodified Program. The output from running a covered work is covered by this License only if the output, given its content, constitutes a covered work. This License acknowledges your rights of fair use or other equivalent, as provided by copyright law. You may make, run and propagate covered works that you do not convey, without conditions so long as your license otherwise remains in force. You may convey covered works to others for the sole purpose of having them make modifications exclusively for you, or provide you with facilities for running those works, provided that you comply with the terms of this License in conveying all material for which you do not control copyright. Those thus making or running the covered works for you must do so exclusively on your behalf, under your direction and control, on terms that prohibit them from making any copies of your copyrighted material outside their relationship with you. Conveying under any other circumstances is permitted solely under the conditions stated below. Sublicensing is not allowed; section 10 makes it unnecessary. 3. Protecting Users' Legal Rights From Anti-Circumvention Law. No covered work shall be deemed part of an effective technological measure under any applicable law fulfilling obligations under article 11 of the WIPO copyright treaty adopted on 20 December 1996, or similar laws prohibiting or restricting circumvention of such measures. When you convey a covered work, you waive any legal power to forbid circumvention of technological measures to the extent such circumvention is effected by exercising rights under this License with respect to the covered work, and you disclaim any intention to limit operation or modification of the work as a means of enforcing, against the work's users, your or third parties' legal rights to forbid circumvention of technological measures. 4. Conveying Verbatim Copies. You may convey verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice; keep intact all notices stating that this License and any non-permissive terms added in accord with section 7 apply to the code; keep intact all notices of the absence of any warranty; and give all recipients a copy of this License along with the Program. You may charge any price or no price for each copy that you convey, and you may offer support or warranty protection for a fee. 5. Conveying Modified Source Versions. You may convey a work based on the Program, or the modifications to produce it from the Program, in the form of source code under the terms of section 4, provided that you also meet all of these conditions: a) The work must carry prominent notices stating that you modified it, and giving a relevant date. b) The work must carry prominent notices stating that it is released under this License and any conditions added under section 7. This requirement modifies the requirement in section 4 to "keep intact all notices". c) You must license the entire work, as a whole, under this License to anyone who comes into possession of a copy. This License will therefore apply, along with any applicable section 7 additional terms, to the whole of the work, and all its parts, regardless of how they are packaged. This License gives no permission to license the work in any other way, but it does not invalidate such permission if you have separately received it. d) If the work has interactive user interfaces, each must display Appropriate Legal Notices; however, if the Program has interactive interfaces that do not display Appropriate Legal Notices, your work need not make them do so. A compilation of a covered work with other separate and independent works, which are not by their nature extensions of the covered work, and which are not combined with it such as to form a larger program, in or on a volume of a storage or distribution medium, is called an "aggregate" if the compilation and its resulting copyright are not used to limit the access or legal rights of the compilation's users beyond what the individual works permit. Inclusion of a covered work in an aggregate does not cause this License to apply to the other parts of the aggregate. 6. Conveying Non-Source Forms. You may convey a covered work in object code form under the terms of sections 4 and 5, provided that you also convey the machine-readable Corresponding Source under the terms of this License, in one of these ways: a) Convey the object code in, or embodied in, a physical product (including a physical distribution medium), accompanied by the Corresponding Source fixed on a durable physical medium customarily used for software interchange. b) Convey the object code in, or embodied in, a physical product (including a physical distribution medium), accompanied by a written offer, valid for at least three years and valid for as long as you offer spare parts or customer support for that product model, to give anyone who possesses the object code either (1) a copy of the Corresponding Source for all the software in the product that is covered by this License, on a durable physical medium customarily used for software interchange, for a price no more than your reasonable cost of physically performing this conveying of source, or (2) access to copy the Corresponding Source from a network server at no charge. c) Convey individual copies of the object code with a copy of the written offer to provide the Corresponding Source. This alternative is allowed only occasionally and noncommercially, and only if you received the object code with such an offer, in accord with subsection 6b. d) Convey the object code by offering access from a designated place (gratis or for a charge), and offer equivalent access to the Corresponding Source in the same way through the same place at no further charge. You need not require recipients to copy the Corresponding Source along with the object code. If the place to copy the object code is a network server, the Corresponding Source may be on a different server (operated by you or a third party) that supports equivalent copying facilities, provided you maintain clear directions next to the object code saying where to find the Corresponding Source. Regardless of what server hosts the Corresponding Source, you remain obligated to ensure that it is available for as long as needed to satisfy these requirements. e) Convey the object code using peer-to-peer transmission, provided you inform other peers where the object code and Corresponding Source of the work are being offered to the general public at no charge under subsection 6d. A separable portion of the object code, whose source code is excluded from the Corresponding Source as a System Library, need not be included in conveying the object code work. A "User Product" is either (1) a "consumer product", which means any tangible personal property which is normally used for personal, family, or household purposes, or (2) anything designed or sold for incorporation into a dwelling. In determining whether a product is a consumer product, doubtful cases shall be resolved in favor of coverage. For a particular product received by a particular user, "normally used" refers to a typical or common use of that class of product, regardless of the status of the particular user or of the way in which the particular user actually uses, or expects or is expected to use, the product. A product is a consumer product regardless of whether the product has substantial commercial, industrial or non-consumer uses, unless such uses represent the only significant mode of use of the product. "Installation Information" for a User Product means any methods, procedures, authorization keys, or other information required to install and execute modified versions of a covered work in that User Product from a modified version of its Corresponding Source. The information must suffice to ensure that the continued functioning of the modified object code is in no case prevented or interfered with solely because modification has been made. If you convey an object code work under this section in, or with, or specifically for use in, a User Product, and the conveying occurs as part of a transaction in which the right of possession and use of the User Product is transferred to the recipient in perpetuity or for a fixed term (regardless of how the transaction is characterized), the Corresponding Source conveyed under this section must be accompanied by the Installation Information. But this requirement does not apply if neither you nor any third party retains the ability to install modified object code on the User Product (for example, the work has been installed in ROM). The requirement to provide Installation Information does not include a requirement to continue to provide support service, warranty, or updates for a work that has been modified or installed by the recipient, or for the User Product in which it has been modified or installed. Access to a network may be denied when the modification itself materially and adversely affects the operation of the network or violates the rules and protocols for communication across the network. Corresponding Source conveyed, and Installation Information provided, in accord with this section must be in a format that is publicly documented (and with an implementation available to the public in source code form), and must require no special password or key for unpacking, reading or copying. 7. Additional Terms. "Additional permissions" are terms that supplement the terms of this License by making exceptions from one or more of its conditions. Additional permissions that are applicable to the entire Program shall be treated as though they were included in this License, to the extent that they are valid under applicable law. If additional permissions apply only to part of the Program, that part may be used separately under those permissions, but the entire Program remains governed by this License without regard to the additional permissions. When you convey a copy of a covered work, you may at your option remove any additional permissions from that copy, or from any part of it. (Additional permissions may be written to require their own removal in certain cases when you modify the work.) You may place additional permissions on material, added by you to a covered work, for which you have or can give appropriate copyright permission. Notwithstanding any other provision of this License, for material you add to a covered work, you may (if authorized by the copyright holders of that material) supplement the terms of this License with terms: a) Disclaiming warranty or limiting liability differently from the terms of sections 15 and 16 of this License; or b) Requiring preservation of specified reasonable legal notices or author attributions in that material or in the Appropriate Legal Notices displayed by works containing it; or c) Prohibiting misrepresentation of the origin of that material, or requiring that modified versions of such material be marked in reasonable ways as different from the original version; or d) Limiting the use for publicity purposes of names of licensors or authors of the material; or e) Declining to grant rights under trademark law for use of some trade names, trademarks, or service marks; or f) Requiring indemnification of licensors and authors of that material by anyone who conveys the material (or modified versions of it) with contractual assumptions of liability to the recipient, for any liability that these contractual assumptions directly impose on those licensors and authors. All other non-permissive additional terms are considered "further restrictions" within the meaning of section 10. If the Program as you received it, or any part of it, contains a notice stating that it is governed by this License along with a term that is a further restriction, you may remove that term. If a license document contains a further restriction but permits relicensing or conveying under this License, you may add to a covered work material governed by the terms of that license document, provided that the further restriction does not survive such relicensing or conveying. If you add terms to a covered work in accord with this section, you must place, in the relevant source files, a statement of the additional terms that apply to those files, or a notice indicating where to find the applicable terms. Additional terms, permissive or non-permissive, may be stated in the form of a separately written license, or stated as exceptions; the above requirements apply either way. 8. Termination. You may not propagate or modify a covered work except as expressly provided under this License. Any attempt otherwise to propagate or modify it is void, and will automatically terminate your rights under this License (including any patent licenses granted under the third paragraph of section 11). However, if you cease all violation of this License, then your license from a particular copyright holder is reinstated (a) provisionally, unless and until the copyright holder explicitly and finally terminates your license, and (b) permanently, if the copyright holder fails to notify you of the violation by some reasonable means prior to 60 days after the cessation. Moreover, your license from a particular copyright holder is reinstated permanently if the copyright holder notifies you of the violation by some reasonable means, this is the first time you have received notice of violation of this License (for any work) from that copyright holder, and you cure the violation prior to 30 days after your receipt of the notice. Termination of your rights under this section does not terminate the licenses of parties who have received copies or rights from you under this License. If your rights have been terminated and not permanently reinstated, you do not qualify to receive new licenses for the same material under section 10. 9. Acceptance Not Required for Having Copies. You are not required to accept this License in order to receive or run a copy of the Program. Ancillary propagation of a covered work occurring solely as a consequence of using peer-to-peer transmission to receive a copy likewise does not require acceptance. However, nothing other than this License grants you permission to propagate or modify any covered work. These actions infringe copyright if you do not accept this License. Therefore, by modifying or propagating a covered work, you indicate your acceptance of this License to do so. 10. Automatic Licensing of Downstream Recipients. Each time you convey a covered work, the recipient automatically receives a license from the original licensors, to run, modify and propagate that work, subject to this License. You are not responsible for enforcing compliance by third parties with this License. An "entity transaction" is a transaction transferring control of an organization, or substantially all assets of one, or subdividing an organization, or merging organizations. If propagation of a covered work results from an entity transaction, each party to that transaction who receives a copy of the work also receives whatever licenses to the work the party's predecessor in interest had or could give under the previous paragraph, plus a right to possession of the Corresponding Source of the work from the predecessor in interest, if the predecessor has it or can get it with reasonable efforts. You may not impose any further restrictions on the exercise of the rights granted or affirmed under this License. For example, you may not impose a license fee, royalty, or other charge for exercise of rights granted under this License, and you may not initiate litigation (including a cross-claim or counterclaim in a lawsuit) alleging that any patent claim is infringed by making, using, selling, offering for sale, or importing the Program or any portion of it. 11. Patents. A "contributor" is a copyright holder who authorizes use under this License of the Program or a work on which the Program is based. The work thus licensed is called the contributor's "contributor version". A contributor's "essential patent claims" are all patent claims owned or controlled by the contributor, whether already acquired or hereafter acquired, that would be infringed by some manner, permitted by this License, of making, using, or selling its contributor version, but do not include claims that would be infringed only as a consequence of further modification of the contributor version. For purposes of this definition, "control" includes the right to grant patent sublicenses in a manner consistent with the requirements of this License. Each contributor grants you a non-exclusive, worldwide, royalty-free patent license under the contributor's essential patent claims, to make, use, sell, offer for sale, import and otherwise run, modify and propagate the contents of its contributor version. In the following three paragraphs, a "patent license" is any express agreement or commitment, however denominated, not to enforce a patent (such as an express permission to practice a patent or covenant not to sue for patent infringement). To "grant" such a patent license to a party means to make such an agreement or commitment not to enforce a patent against the party. If you convey a covered work, knowingly relying on a patent license, and the Corresponding Source of the work is not available for anyone to copy, free of charge and under the terms of this License, through a publicly available network server or other readily accessible means, then you must either (1) cause the Corresponding Source to be so available, or (2) arrange to deprive yourself of the benefit of the patent license for this particular work, or (3) arrange, in a manner consistent with the requirements of this License, to extend the patent license to downstream recipients. "Knowingly relying" means you have actual knowledge that, but for the patent license, your conveying the covered work in a country, or your recipient's use of the covered work in a country, would infringe one or more identifiable patents in that country that you have reason to believe are valid. If, pursuant to or in connection with a single transaction or arrangement, you convey, or propagate by procuring conveyance of, a covered work, and grant a patent license to some of the parties receiving the covered work authorizing them to use, propagate, modify or convey a specific copy of the covered work, then the patent license you grant is automatically extended to all recipients of the covered work and works based on it. A patent license is "discriminatory" if it does not include within the scope of its coverage, prohibits the exercise of, or is conditioned on the non-exercise of one or more of the rights that are specifically granted under this License. You may not convey a covered work if you are a party to an arrangement with a third party that is in the business of distributing software, under which you make payment to the third party based on the extent of your activity of conveying the work, and under which the third party grants, to any of the parties who would receive the covered work from you, a discriminatory patent license (a) in connection with copies of the covered work conveyed by you (or copies made from those copies), or (b) primarily for and in connection with specific products or compilations that contain the covered work, unless you entered into that arrangement, or that patent license was granted, prior to 28 March 2007. Nothing in this License shall be construed as excluding or limiting any implied license or other defenses to infringement that may otherwise be available to you under applicable patent law. 12. No Surrender of Others' Freedom. If conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot convey a covered work so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not convey it at all. For example, if you agree to terms that obligate you to collect a royalty for further conveying from those to whom you convey the Program, the only way you could satisfy both those terms and this License would be to refrain entirely from conveying the Program. 13. Use with the GNU Affero General Public License. Notwithstanding any other provision of this License, you have permission to link or combine any covered work with a work licensed under version 3 of the GNU Affero General Public License into a single combined work, and to convey the resulting work. The terms of this License will continue to apply to the part which is the covered work, but the special requirements of the GNU Affero General Public License, section 13, concerning interaction through a network will apply to the combination as such. 14. Revised Versions of this License. The Free Software Foundation may publish revised and/or new versions of the GNU General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Program specifies that a certain numbered version of the GNU General Public License "or any later version" applies to it, you have the option of following the terms and conditions either of that numbered version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of the GNU General Public License, you may choose any version ever published by the Free Software Foundation. If the Program specifies that a proxy can decide which future versions of the GNU General Public License can be used, that proxy's public statement of acceptance of a version permanently authorizes you to choose that version for the Program. Later license versions may give you additional or different permissions. However, no additional obligations are imposed on any author or copyright holder as a result of your choosing to follow a later version. 15. Disclaimer of Warranty. THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 16. Limitation of Liability. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. 17. Interpretation of Sections 15 and 16. If the disclaimer of warranty and limitation of liability provided above cannot be given local legal effect according to their terms, reviewing courts shall apply local law that most closely approximates an absolute waiver of all civil liability in connection with the Program, unless a warranty or assumption of liability accompanies a copy of the Program in return for a fee. END OF TERMS AND CONDITIONS How to Apply These Terms to Your New Programs If you develop a new program, and you want it to be of the greatest possible use to the public, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms. To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively state the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. Copyright (C) This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . Also add information on how to contact you by electronic and paper mail. If the program does terminal interaction, make it output a short notice like this when it starts in an interactive mode: Copyright (C) This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details. The hypothetical commands `show w' and `show c' should show the appropriate parts of the General Public License. Of course, your program's commands might be different; for a GUI interface, you would use an "about box". You should also get your employer (if you work as a programmer) or school, if any, to sign a "copyright disclaimer" for the program, if necessary. For more information on this, and how to apply and follow the GNU GPL, see . The GNU General Public License does not permit incorporating your program into proprietary programs. If your program is a subroutine library, you may consider it more useful to permit linking proprietary applications with the library. If this is what you want to do, use the GNU Lesser General Public License instead of this License. But first, please read . tabbar-2.2/README000066400000000000000000000004661332640313100134720ustar00rootroot00000000000000To produce the tiff images: convert close-tab12.png close-tab24.png close-tab.tiff To set DPI correctly: convert -units PixelsPerInch close-tab24.png -density 184 close-tab\@2x.png convert -units PixelsPerInch close-tab12.png -density 92 close-tab.png convert close-tab.png close-tab\@2x.png close-tab.tiff tabbar-2.2/README.markdown000066400000000000000000000015511332640313100153070ustar00rootroot00000000000000TabBarMode ========== This is a fork of the [Aquamacs](https://aquamacs.org/) [TabBarMode](http://www.emacswiki.org/emacs/TabBarMode) implementation which is an up-to date version of this minor mode. TabBarMode is perfectly portable between different Emacs implementations and this repository is intended to provide just that. Since the repository is a filtered clone of the Aquamacs Git repo and hence it should be perfectly possible to track changes made upstream. Settings ======== If you are experiencing slowdowns when using tabbar with graphics it might be caused by issues with transparency. Try setting `(setq 'tabbar-use-images nil)` to work around this issue. Originally identified by [Tom Regner](http://stackoverflow.com/users/594138/tom-regner) on [stackoverflow](http://stackoverflow.com/questions/8520531/tabbar-mode-brings-editing-to-a-crawling-halt). tabbar-2.2/aquamacs-compat.el000066400000000000000000000033671332640313100162130ustar00rootroot00000000000000;;; aquamacs-compat.el --- Aquamacs compatibility layer ;; Copyright (C) 2005-2014 David Reitter ;; Copyright (C) 2014 David Holm ;; Author: David Holm ;; Version 0.1 ;; This file is not part of GNU Emacs. ;; This program is free software; you can redistribute it and/or ;; modify it under the terms of the GNU General Public License as ;; published by the Free Software Foundation; either version 3, or (at ;; your option) any later version. ;; This program is distributed in the hope that it will be useful, but ;; WITHOUT ANY WARRANTY; without even the implied warranty of ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ;; General Public License for more details. ;; You should have received a copy of the GNU General Public License ;; along with this program; see the file COPYING. If not, write to ;; the Free Software Foundation, Inc., 51 Franklin Street, Fifth ;; Floor, Boston, MA 02110-1301, USA. ;;; Commentary: ;; This is an Aquamacs compatibility layer which provides the missing ;; symbols required to use tabbar-mode on other emacsen. ;;; Code: ;;; src/ ;;; ;;; Aquamacs builtin from window.c. (defvar header-line-inhibit-window-list nil "List of windows in which no header line is shown.") ;;; aquamacs/src/site-lisp/macosx/ ;;; ;;; Aquamacs function from mac-extra-functions.el. ;; according to Apple's guidelines, we should ;; always go for "untitled", "untitled 2", ... (defun mac-new-buffer-name (name &optional n) (if (not (get-buffer name)) name (setq n (if n (+ n 1) 2)) (let ((new-name (concat name " " (int-to-string n)))) (if (not (get-buffer new-name)) new-name (mac-new-buffer-name name n))))) (provide 'aquamacs-compat) ;;; aquamacs-compat.el ends here tabbar-2.2/aquamacs-tabbar.el000066400000000000000000001057731332640313100161670ustar00rootroot00000000000000;; -*-no-byte-compile: t; -*- ;; Aquamacs-tabbar.el --- "Look and feel" improvements to tabbar.el. Uses ;; Window Tabs by default: Tab-set is specific to each window, and tabbar ;; is hidden when only a single tab exists for that window. ;; This file is part of Aquamacs Emacs. ;; This program is free software; you can redistribute it and/or ;; modify it under the terms of the GNU General Public License as ;; published by the Free Software Foundation; either version 3, or (at ;; your option) any later version. ;; This program is distributed in the hope that it will be useful, but ;; WITHOUT ANY WARRANTY; without even the implied warranty of ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ;; General Public License for more details. ;; You should have received a copy of the GNU General Public License ;; along with this program; see the file COPYING. If not, write to ;; the Free Software Foundation, Inc., 51 Franklin Street, Fifth ;; Floor, Boston, MA 02110-1301, USA. ;; Author: Nathaniel Cunningham ;; Maintainer: Nathaniel Cunningham ;; (C) Copyright 2008, 2012, 2014: the Aquamacs Project ;; load original tabbar-mode (require 'tabbar) (require 'aquamacs-compat) (require 'one-buffer-one-frame) (require 'aquamacs-tools) ;; check version of tabbar (unless (and (boundp 'tabbar-version) (string< "1.9999" tabbar-version)) (message "Tabbar version too low. Uninstall %s." (locate-library "tabbar")) (let ((load-path (list default-directory))) (load "tabbar/tabbar.el"))) (when (and (boundp 'tabbar-version) (not (equal "2.2" tabbar-version))) (message "Warning: possibly incompatible tabbar version installed in %s." (locate-library "tabbar"))) ;; modify various settings: ;; eliminate gap between header-line and toolbar ;; save current value of tool-bar-border, ;; to reset when tabbar-mode is turned off (add-hook 'tabbar-init-hook (lambda () (setq tool-bar-border-saved tool-bar-border tool-bar-border 0))) (add-hook 'tabbar-quit-hook (lambda () (setq tool-bar-border tool-bar-border-saved tool-bar-border-saved nil))) ;; used by tabbar-window-update-tabsets-when-idle (defmacro fast-screen-refresh (&rest code) `(let ((tabbar-window-immediate-screen-fresh (or tabbar-window-immediate-screen-fresh (interactive-p)))) ,@code )) ;; improve tabbar-selected-tab such that it defaults to (tabbar-current-tabset) ;; if no tabset is passed (defsubst tabbar-selected-tab (&optional tabset) "Return the tab selected in TABSET. If no TABSET is specified, use (tabbar-current-tabset)." (get (or tabset (tabbar-current-tabset) (tabbar-current-tabset t)) 'select)) (defvar tabbar-close-tab-function nil "Function to call to close a tabbar tab. Passed a single argument, the tab construct to be closed.") (defvar tabbar-new-tab-function nil "Function to call to create a new buffer in tabbar-mode. Optional single argument is the MODE for the new buffer.") ;; for buffer tabs, use the usual command to close/kill a buffer (defun tabbar-buffer-close-tab (tab) (let ((buffer (tabbar-tab-value tab)) (one-buffer-one-frame nil)) (with-current-buffer buffer (close-current-window-asktosave)))) (setq tabbar-close-tab-function 'tabbar-window-close-tab) (defun tabbar-close-tab (&optional tab) "Generic function to close a tabbar tab. Calls function named in tabbar-close-tab-function. Passes a single argument: the tab construct to be closed. If no tab is specified, (tabbar-selected-tab) is used" (interactive) (fast-screen-refresh (let ((thetab (or tab (tabbar-selected-tab)))) (funcall tabbar-close-tab-function thetab)))) ;; change faces for better-looking tabs (and more obvious selected tab!) ;; full face specification to avoid inheriting from the frame font ;; or from mode-line (set-face-attribute 'tabbar-default nil :inherit nil :height 110 :weight 'normal :width 'normal :slant 'normal :underline nil :strike-through nil ;; inherit from frame :inverse-video :stipple nil :background "gray80" :foreground "black" ;; :box '(:line-width 2 :color "white" :style nil) :box nil :family "Lucida Grande") (set-face-attribute 'tabbar-selected nil :background "gray95" :foreground "gray20" :inherit 'tabbar-default :box '(:line-width 3 :color "grey95" :style nil)) ;; :box '(:line-width 2 :color "white" :style released-button)) (set-face-attribute 'tabbar-unselected nil :inherit 'tabbar-default :background "gray80" :box '(:line-width 3 :color "grey80" :style nil)) (defface tabbar-selected-highlight '((t :foreground "black" :background "gray95")) "Face for selected, highlighted tabs." :group 'tabbar) (defface tabbar-unselected-highlight '((t ;; :foreground "black" ;; :background "grey75" ;; :box (:line-width 3 :color "grey75" :style nil) )) "Face for unselected, highlighted tabs." :group 'tabbar) (set-face-attribute 'tabbar-button nil :inherit 'tabbar-default :box nil) (set-face-attribute 'tabbar-separator nil :background "grey50" :foreground "grey50" :height 1.0) (setq tabbar-separator '(1)) ;; set tabbar-separator size to 1 pixel (defface tabbar-selected-modified '((t :inherit tabbar-selected :weight bold :height 110 )) "Face used for unselected tabs." :group 'tabbar) (defface tabbar-unselected-modified '((t :inherit tabbar-unselected :weight bold :height 110 )) "Face used for unselected tabs." :group 'tabbar) (defface tabbar-key-binding '((t :foreground "white")) "Face for unselected, highlighted tabs." :group 'tabbar) ;; do not let color themes override tabbar faces (aquamacs-set-defaults '((color-theme-illegal-faces "^\\(w3-\\|tabbar-\\)"))) ;; you may redefine these: (defvar tabbar-key-binding-modifier-list '(alt) "List of modifiers to be used for keys bound to tabs. Must call `tabbar-define-access-keys' or toggle `tabbar-mode' for changes to this variable to take effect.") (defvar tabbar-key-binding-keys '((49 kp-1) (50 kp-2) (51 kp-3) (52 kp-4) (53 kp-5) (54 kp-6) (55 kp-7) (56 kp-8) (57 kp-9) (48 kp-0)) "Codes of ten keys bound to tabs (without modifiers. This is a list with 10 elements, one for each of the first 10 tabs. Each element is a list of keys, either of which can be used in conjunction with the modifiers defined in `tabbar-key-binding-modifier-list'. Must call `tabbar-define-access-keys' or toggle `tabbar-mode' for changes to this variable to take effect.") (defsubst tabbar-key-command (index) ; command name (intern (format "tabbar-select-tab-%s" index))) (eval-when-compile (require 'cl)) (defun tabbar-define-access-keys (&optional modifiers keys) "Set tab access keys for `tabbar-mode'. MODIFIERS as in `tabbar-key-binding-modifier-list', and KEYS defines the elements to use for `tabbar-key-binding-keys'." (if modifiers (setq tabbar-key-binding-modifier-list modifiers)) (if keys (setq tabbar-key-binding-keys keys)) (loop for keys in tabbar-key-binding-keys for ni from 1 to 10 do (let ((name (tabbar-key-command ni))) (eval `(defun ,name () "Select tab in selected window." (interactive) (tabbar-select-tab-by-index ,(- ni 1)))) ;; store label in property of command name symbol (put name 'label (format "%c" (car keys))) (loop for key in keys do (define-key tabbar-mode-map (vector (append tabbar-key-binding-modifier-list (list key))) name))))) (defun tabbar-select-tab-by-index (index) ;; (let ((vis-index (+ index (or (get (tabbar-current-tabset) 'start) 0)))) (unless (> (length (tabbar-tabs (tabbar-current-tabset))) 1) ;; better window (with tabs)in this frame? (let ((better-w)) (walk-windows (lambda (w) (and (not better-w) (with-selected-window w (if (> (length (tabbar-tabs (tabbar-current-tabset t))) 1) (setq better-w w))))) 'avoid-minibuf (selected-frame)) (if better-w (select-window better-w)))) (tabbar-window-select-a-tab (nth index (tabbar-tabs (tabbar-current-tabset))))) (defun tabbar-window-select-a-tab (tab) "Select TAB" (let ((one-buffer-one-frame nil) (buffer (tabbar-tab-value tab))) (when buffer (set-window-dedicated-p (selected-window) nil) (let ((prevtab (tabbar-get-tab (window-buffer (selected-window)) (tabbar-tab-tabset tab))) (marker (cond ((bobp) (point-min-marker)) ((eobp) (point-max-marker)) (t (point-marker))))) (set-marker-insertion-type marker t) (assq-set prevtab marker 'tab-points)) (switch-to-buffer buffer) (let ((new-pt (cdr (assq tab tab-points)))) (and new-pt (eq (marker-buffer new-pt) (window-buffer (selected-window))) (let ((pos (marker-position new-pt))) (unless (eq pos (point)) (if transient-mark-mode (deactivate-mark)) (goto-char pos)) (set-marker new-pt nil) ;; delete marker )))))) ; (marker-insertion-type (cdr (car tab-points))) ;; function for closing a tab via context menu. Kills buffer if doesn't ;; appear in other tabs. (defun tabbar-close-clicked-tab (event) (interactive "@e") (when (tabbar-click-p event) (let* ((clicklocation (posn-string (event-start event))) (clickedtab (get-text-property (cdr clicklocation) 'tabbar-tab (car clicklocation)))) (save-current-buffer ;; (tabbar-window-close-tab clickedtab))))) (tabbar-close-tab clickedtab))))) ;; function for closing all other tabs via context menu (defun tabbar-close-other-tabs (event) "Close all tabs except the one where context menu was generated via click" (interactive "@e") (when (tabbar-click-p event) (let* ((clicklocation (posn-string (event-start event))) (clickedtab (get-text-property (cdr clicklocation) 'tabbar-tab (car clicklocation))) (tablist (tabbar-tabs (tabbar-tab-tabset clickedtab)))) ; (save-current-buffer (dolist (thistab tablist (tabbar-tab-value clickedtab)) (unless (equal thistab clickedtab) ;; (tabbar-window-close-tab thistab))))));) (tabbar-close-tab thistab)))))) ;; function for removing a tab via context menu, without killing buffer (defun tabbar-delete-clicked-tab (event) (interactive "@e") (when (tabbar-click-p event) (let* ((clicklocation (posn-string (event-start event))) (clickedtab (get-text-property (cdr clicklocation) 'tabbar-tab (car clicklocation)))) ;; (save-current-buffer ;; (tabbar-window-close-tab clickedtab))))) (tabbar-window-delete-tab clickedtab)))) (defun tabbar-delete-current-tab () "Delete the current tab." (interactive) (if tabbar-mode (tabbar-window-delete-tab (tabbar-selected-tab)) (delete-window))) ;; function to open a new tab, suppressing new frame creation (defun tabbar-new-tab (&optional mode) "Creates a new tab, containing an empty buffer (with major-mode MODE if specified), in current window." (interactive) (let ((one-buffer-one-frame nil)) (new-empty-buffer nil mode))) (setq tabbar-new-tab-function 'tabbar-new-tab) ;; function for duplicating an existing tab in a new frame (defun tabbar-new-frame-with-clicked-buffer (event) (interactive "@e") (when (tabbar-click-p event) (let* ((clicklocation (posn-string (event-start event))) (clickedtab (get-text-property (cdr clicklocation) 'tabbar-tab (car clicklocation))) (buffer (tabbar-tab-value clickedtab))) (with-current-buffer buffer (make-frame-command))))) ;; Opens clicked tab in a new frame, and deletes clicked tab ;; This function/implementation is specific to `window tabs' -- can't be done ;; with `buffer tabs' (defun tabbar-move-clicked-buffer-to-new-frame (event) (interactive "@e") (when (tabbar-click-p event) (let* ((clicklocation (posn-string (event-start event))) (clickedtab (get-text-property (cdr clicklocation) 'tabbar-tab (car clicklocation))) (buffer (tabbar-tab-value clickedtab)) (wnumber (string-to-number (symbol-name (tabbar-tab-tabset tab)))) (wind (window-number-get-window wnumber))) (with-current-buffer buffer (make-frame-command)) (with-selected-window wind (tabbar-close-tab clickedtab))))) (defun tabbar-move-current-buffer-to-new-frame () (interactive) (let* ((tab (tabbar-selected-tab (tabbar-current-tabset t))) (buffer (tabbar-tab-value tab)) (wnumber (string-to-number (symbol-name (tabbar-tab-tabset tab)))) (wind (window-number-get-window wnumber))) (with-current-buffer buffer (make-frame-command)) (with-selected-window wind (tabbar-close-tab tab)))) ;; keymap for tabbar context menu (defvar tabbar-context-menu-map (let ((map (make-sparse-keymap))) (define-key map [removetab] (cons "Hide Tab" 'tabbar-delete-clicked-tab)) (define-key map [duptab] (cons "Duplicate Tab in New Frame" 'tabbar-new-frame-with-clicked-buffer)) (define-key map [movetab] (cons "Move Tab to New Frame" 'tabbar-move-clicked-buffer-to-new-frame)) (define-key map [closeothers] (cons "Close Other Tabs" 'tabbar-close-other-tabs)) (define-key map [closetab] (cons "Close Tab" 'tabbar-close-clicked-tab)) (define-key map [newtab] (cons "New Buffer in New Tab" 'tabbar-new-tab)) map) "Keymap for the Tabbar context menu.") ;; keymap for tabbar context menu (defvar tabbar-empty-context-menu-map (let ((map (make-sparse-keymap))) (define-key map [mergetabs] (cons "Merge All Windows" 'tabbar-window-merge-windows)) (define-key map [newtab] (cons "New Buffer in New Tab" 'tabbar-new-tab)) map) "Keymap for the context menu of the empty portion of tab bar.") ;; modify hints to give only the buffer name (defun tabbar-buffer-help-on-tab (tab) "Return the help string shown when mouse is onto TAB." (if tabbar--buffer-show-groups (let* ((tabset (tabbar-tab-tabset tab)) (tab (tabbar-selected-tab tabset))) (format "click: switch to buffer %S in group [%s]" (buffer-name (tabbar-tab-value tab)) tabset)) (format "%s" (buffer-name (tabbar-tab-value tab))) )) ;; provide new actions for middle-click/right-click on tabs (defun tabbar-buffer-select-tab (event tab &optional prefix) "On mouse EVENT, select TAB." (let ((mouse-button (event-basic-type event)) (one-buffer-one-frame nil) (buffer (tabbar-tab-value tab))) (cond ((eq mouse-button 'mouse-3) (popup-menu tabbar-context-menu-map event prefix)) (t (switch-to-buffer buffer))) ;; Don't show groups. (tabbar-buffer-show-groups nil) )) (defsubst tabbar-normalize-image (image &optional margin nomask) "Make IMAGE centered and transparent. If optional MARGIN is non-nil, it must be a number of pixels to add as an extra margin around the image. If optional NOMASK is non-nil, no mask property is included." (let ((plist (cdr image))) (or (plist-get plist :ascent) (setq plist (plist-put plist :ascent 'center))) (or (plist-get plist :mask) (unless nomask (setq plist (plist-put plist :mask '(heuristic t))))) (or (not (natnump margin)) (plist-get plist :margin) (plist-put plist :margin margin)) (setcdr image plist)) image) ;; use images for tabbar buttons (defun tabbar-button-label (name) ;; redefine tabbar-button-label to eliminate 1-pixel border around images "Return a label for button NAME. That is a pair (ENABLED . DISABLED), where ENABLED and DISABLED are respectively the appearance of the button when enabled and disabled. They are propertized strings which could display images, as specified by the variable `tabbar-NAME-button'." (let* ((btn (symbol-value (intern-soft (format "tabbar-%s-button" name)))) (on (tabbar-find-image (cdar btn))) (off (and on (tabbar-find-image (cddr btn))))) (when on (tabbar-normalize-image on 0 t) (if off (tabbar-normalize-image off 0 t) ;; If there is no disabled button image, derive one from the ;; button enabled image. (setq off (tabbar-disable-image on)))) (cons (propertize (or (caar btn) " ") 'display on) (propertize (or (cadr btn) " ") 'display off)))) (defun tabbar-buffer-button-label (name) ;; redefine tabbar-buffer-button-label to eliminate 1-pixel border around images "Return a label for button NAME. That is a pair (ENABLED . DISABLED), where ENABLED and DISABLED are respectively the appearance of the button when enabled and disabled. They are propertized strings which could display images, as specified by the variable `tabbar-button-label'. When NAME is 'home, return a different ENABLED button if showing tabs or groups. Call the function `tabbar-button-label' otherwise." (let ((lab (tabbar-button-label name))) (when (eq name 'home) (let* ((btn tabbar-buffer-home-button) (on (tabbar-find-image (cdar btn))) (off (tabbar-find-image (cddr btn)))) ;; When `tabbar-buffer-home-button' does not provide a value, ;; default to the enabled value of `tabbar-home-button'. (if on (tabbar-normalize-image on 0 t) (setq on (get-text-property 0 'display (car lab)))) (if off (tabbar-normalize-image off 0 t) (setq off (get-text-property 0 'display (car lab)))) (setcar lab (if tabbar--buffer-show-groups (propertize (or (caar btn) (car lab)) 'display on) (propertize (or (cadr btn) (car lab)) 'display off))) )) lab)) (setq tabbar-home-button-enabled-image '((:type png :file "down.png"))) (setq tabbar-home-button-disabled-image '((:type png :file "up.png"))) (setq tabbar-home-button (cons (cons "[o]" tabbar-home-button-enabled-image) (cons "[x]" tabbar-home-button-disabled-image))) (setq tabbar-buffer-home-button (cons (cons "[+]" tabbar-home-button-enabled-image) (cons "[-]" tabbar-home-button-disabled-image))) (setq tabbar-scroll-left-button-enabled-image '((:type tiff :file "left.tiff"))) (setq tabbar-scroll-left-button-disabled-image '((:type tiff :file "left_disabled.tiff"))) (setq tabbar-scroll-left-button (cons (cons " <" tabbar-scroll-left-button-enabled-image) (cons " =" tabbar-scroll-left-button-disabled-image))) (setq tabbar-scroll-right-button-enabled-image '((:type tiff :file "right.tiff"))) (setq tabbar-scroll-right-button-disabled-image '((:type tiff :file "right_disabled.tiff"))) (setq tabbar-scroll-right-button (cons (cons " >" tabbar-scroll-right-button-enabled-image) (cons " =" tabbar-scroll-right-button-disabled-image))) (setq tabbar-close-tab-button '((:type tiff :file "close-tab.tiff"))) ;; allow fast-clicking through lists of tabs (defsubst tabbar-click-p (event) "Return non-nil if EVENT is a mouse click event." ;;counts as a click even if it's the last of a double- or triple-click; ;;allows fast cycling through tabs with the mouse. (and (or (memq 'click (event-modifiers event)) (memq 'double (event-modifiers event)) (memq 'triple (event-modifiers event))) ;; don't count double- or triple-drag events (not (memq 'drag (event-modifiers event)))) ) (defun tabbar-check-overflow (tabset &optional noscroll) "Return t if the current tabbar is longer than the header line. If NOSCROLL is non-nil, exclude the tabbar-scroll buttons in the check." (let ((tabs (tabbar-view tabset)) elts) (while tabs (setq elts (cons (tabbar-line-tab (car tabs)) elts) tabs (cdr tabs))) (setq elts (nreverse elts)) (with-temp-buffer (let ((truncate-partial-width-windows nil) (inhibit-modification-hooks t) deactivate-mark ;; Prevent deactivation of the mark! start) (setq truncate-lines nil buffer-undo-list t) (apply 'insert (tabbar-dummy-line-buttons noscroll)) (setq start (point)) (delete-region start (point-max)) (goto-char (point-max)) (apply 'insert elts) (goto-char (point-min)) (> (vertical-motion 1) 0))))) ;; redefine tabbar-click-on-tab with an additional argument that can ;; trigger closing the tab instead of selecting it! (defsubst tabbar-click-on-tab (tab &optional type action) "Handle a mouse click event on tab TAB. Call `tabbar-select-tab-function' with the received, or simulated mouse click event, and TAB. Optional argument TYPE is a mouse click event type (see the function `tabbar-make-mouse-event' for details)." (let* ((mouse-event (tabbar-make-mouse-event type)) (mouse-button (event-basic-type mouse-event))) (if (eq action 'close-tab) (when (and (eq mouse-button 'mouse-1) tabbar-close-tab-function) (funcall tabbar-close-tab-function tab)) (when tabbar-select-tab-function (funcall tabbar-select-tab-function (tabbar-make-mouse-event type) tab) (tabbar-display-update))))) (defun tabbar-select-tab-callback (event) "Handle a mouse EVENT on a tab. Pass mouse click events on a tab to `tabbar-click-on-tab'." (interactive "@e") (when (tabbar-click-p event) (let ((target (posn-string (event-start event)))) (tabbar-click-on-tab (get-text-property (cdr target) 'tabbar-tab (car target)) event (get-text-property (cdr target) 'tabbar-action (car target)))))) (defcustom tabbar-show-key-bindings t "Decide whether to number the tabs showing their key bindings." :group 'Aquamacs) (defsubst tabbar-line-tab (tab) "Return the display representation of tab TAB. That is, a propertized string used as an `header-line-format' template element. Call `tabbar-tab-label-function' to obtain a label for TAB." (let* ((selected-p (tabbar-selected-p tab (tabbar-current-tabset))) (close-button-image (tabbar-find-image tabbar-close-tab-button)) (mouse-face (if selected-p 'tabbar-selected-highlight 'tabbar-unselected-highlight)) (text-face (if selected-p 'tabbar-selected 'tabbar-unselected)) (close-button (propertize "[x]" 'tabbar-tab tab 'local-map (tabbar-make-tab-keymap tab) 'tabbar-action 'close-tab ;; 'help-echo 'tabbar-help-on-tab ;; no help echo: it's redundant 'mouse-face mouse-face 'face text-face 'pointer 'arrow 'display (tabbar-normalize-image close-button-image 0 'nomask))) (display-label (propertize (if tabbar-tab-label-function (funcall tabbar-tab-label-function tab) tab) 'tabbar-tab tab 'local-map (tabbar-make-tab-keymap tab) ;; 'help-echo 'tabbar-help-on-tab ;; no help echo: it's redundant 'mouse-face mouse-face 'face (cond ((and selected-p (buffer-modified-p (tabbar-tab-value tab))) 'tabbar-selected-modified) ((and (not selected-p) (buffer-modified-p (tabbar-tab-value tab))) 'tabbar-unselected-modified) ((and selected-p (not (buffer-modified-p (tabbar-tab-value tab)))) 'tabbar-selected) (t 'tabbar-unselected)) 'pointer 'arrow)) (key-label (if (and tabbar-show-key-bindings (boundp 'tabbar-line-tabs) tabbar-line-tabs) (let* ((mm (member tab tabbar-line-tabs) ) ;; calc position (i.e., like position from cl-seq) (index (if mm (- (length tabbar-line-tabs) (length mm))))) (if (and index (fboundp (tabbar-key-command (+ 1 index)))) (propertize (get (tabbar-key-command (+ 1 index)) 'label) ;(format "%s" (+ 1 index)) 'mouse-face mouse-face ;; same mouse-face leads to joint mouse activation for all elements 'face (list 'tabbar-key-binding text-face) ;; does not work ) "") ) ""))) (concat close-button display-label key-label tabbar-separator-value))) (defun tabbar-dummy-line-buttons (&optional noscroll) "Return a list of propertized strings for placeholders for the tab bar buttons. These are used to determine the size of the tab bar -- and hence the enabled/ disabled state of the tab bar buttons -- so they always carry a disabled state. This avoids an infinite loop. If NOSCROLL is non-nil, exclude the tabbar-scroll buttons." (cons (cdr tabbar-home-button-value) (unless noscroll (list (cdr tabbar-scroll-left-button-value) (cdr tabbar-scroll-right-button-value))))) (defun tabbar-line-separator () "Return the display representation of a tab bar separator. That is, a propertized string used as an `header-line-format' template element." (let ((image (tabbar-find-image (cdr tabbar-separator)))) ;; Cache the separator display value in variable ;; `tabbar-separator-value'. (setq tabbar-separator-value (cond (image (propertize " " 'face 'tabbar-separator 'pointer 'arrow 'display (tabbar-normalize-image image))) ((numberp (car tabbar-separator)) (propertize " " 'face 'tabbar-separator 'pointer 'arrow 'display (list 'space :width (list (car tabbar-separator))))) ((propertize (or (car tabbar-separator) " ") 'face 'tabbar-separator 'pointer 'arrow)))) )) (defsubst tabbar-line-buttons (tabset &optional noscroll) "Return a list of propertized strings for tab bar buttons. TABSET is the tab set used to choose the appropriate buttons. If NOSCROLL is non-nil, exclude the tabbar-scroll buttons." (cons (if tabbar-home-function (car tabbar-home-button-value) (cdr tabbar-home-button-value)) (if noscroll (list (propertize " " 'face 'tabbar-default 'display (list 'space :width (list 8))) ) ;; insert tabbar-separator-value here? (list (if (> (tabbar-start tabset) 0) (car tabbar-scroll-left-button-value) (cdr tabbar-scroll-left-button-value)) (if (tabbar-check-overflow tabset) (car tabbar-scroll-right-button-value) (cdr tabbar-scroll-right-button-value)) tabbar-separator-value)))) (defun tabbar-line-format (tabset) "Return the `header-line-format' value to display TABSET." (let* ((sel (tabbar-selected-tab tabset)) (tabs (tabbar-view tabset)) (padcolor (tabbar-background-color)) (noscroll t) (tabbar-line-tabs (tabbar-tabs tabset)) atsel elts scrolled) ;; Initialize buttons and separator values. (or tabbar-separator-value (tabbar-line-separator)) (or tabbar-home-button-value (tabbar-line-button 'home)) (or tabbar-scroll-left-button-value (tabbar-line-button 'scroll-left)) (or tabbar-scroll-right-button-value (tabbar-line-button 'scroll-right)) ;; Make sure we're showing as many tabs as possible. If we're ;; not showing the 1st tab, and we're not overflowing the tab ;; bar, then scroll backward. If this leads to overflowing the ;; tab bar, scroll forward 1 at the end. (while (and (> (get tabset 'start) 0) (not (tabbar-check-overflow tabset))) (tabbar-scroll tabset -1) (setq scrolled t)) ;; if we scrolled until the tabbar overflowed, we went too far. ;; Back up 1 slot. (when (and scrolled (tabbar-check-overflow tabset)) (tabbar-scroll tabset 1)) (when (or (> (tabbar-start tabset) 0) (tabbar-check-overflow tabset)) ;; not all tabs fit -- include scroll buttons (setq noscroll nil)) ;; Track the selected tab to ensure it is always visible. (when tabbar--track-selected (while (not (memq sel tabs)) (tabbar-scroll tabset -1) (setq tabs (tabbar-view tabset))) (while (and tabs (not atsel)) (setq elts (cons (tabbar-line-tab (car tabs)) elts) atsel (eq (car tabs) sel) tabs (cdr tabs))) (setq elts (nreverse elts)) ;; At this point the selected tab is the last elt in ELTS. ;; Scroll TABSET and ELTS until the selected tab becomes ;; visible. ;; because of the post-hoc scrolling, ;; we can't determine the line index beforehand (with-temp-buffer (let ((truncate-partial-width-windows nil) (inhibit-modification-hooks t) deactivate-mark ;; Prevent deactivation of the mark! start) (setq truncate-lines nil buffer-undo-list t) (apply 'insert (tabbar-line-buttons tabset noscroll)) (setq start (point)) (while (and (cdr elts) ;; Always show the selected tab! (progn (delete-region start (point-max)) (goto-char (point-max)) (apply 'insert elts) (goto-char (point-min)) (> (vertical-motion 1) 0))) (tabbar-scroll tabset 1) (setq elts (cdr elts))))) (setq elts (nreverse elts)) (setq tabbar--track-selected nil)) ;; Format remaining tabs. (while tabs (setq elts (cons (tabbar-line-tab (car tabs)) elts) tabs (cdr tabs))) ;; Cache and return the new tab bar. (tabbar-set-template tabset (list (tabbar-line-buttons tabset noscroll) (nreverse elts) (propertize "%-" 'face (list :inherit 'tabbar-default :background padcolor :foreground padcolor) 'pointer 'arrow 'local-map (tabbar-make-tab-keymap "empty tab bar")))) )) (defun tabbar-reformat-tabset (tabset) (tabbar-set-template tabset nil)) (defun tabbar-reformat-all-tabsets () (tabbar-map-tabsets 'tabbar-reformat-tabset)) ;; to do: ;; tabbar-expand should really be done in `tabbar-line-tab' or afterwards, ;; because only then do we know how wide (in pixels) the tab is going to be ;; as it stands, we're duplicating some functions (buffer-modified check, e.g.) ;; and we're just guessing what face is going to be used. (defvar tabbar-char-width 5) ;; (defun tabbar-char-width (&optional tab) ;; "Big Hack." ;; ;; average width of Lucida Grande character. Hack! ;; (if (and tab (buffer-modified-p (tabbar-tab-value tab))) ;; 7 ;; in bold ;; 5)) (defun tabbar-expand (str width &optional tab) "Return an expanded string from STR that fits in the given display WIDTH. WIDTH is specified in terms of character display width in the current buffer; see also `char-width'." (let* ((n (length str)) (sw (string-width str)) (el "...") (ew (string-width el)) (w 0) (i 0)) (cond ((< sw width) (let* ((l-l (max 4 (min (- 75 (/ (* tabbar-char-width n) 2) ) (floor (/ (* (frame-char-width) (- width sw)) 2))))) (sp-r (propertize " " 'display `(space :width ;; subtract width of numbers (, (max 4 (- l-l (if tabbar-show-key-bindings 7 0))))))) (sp-l (propertize " " 'display `(space :width ;; subtract the width of closer button. hard-coded for speed. (,(max 4 (- l-l 14))))))) (concat sp-l str sp-r))) (t str)))) ;; function to unconditionally open a new tab (defun new-tab (&optional major-mode) "Creates a new tab. Turns on `tabbar-mode'." (interactive) (fast-screen-refresh (tabbar-mode 1) (tabbar-new-tab major-mode))) (defun new-tab-or-buffer (&optional mode) "Calls tabbar-new-tab-function if tabbar-mode is on; otherwise, creates a new buffer. Mode for new buffer can optionally be specified." (interactive) (if (and (boundp tabbar-mode) tabbar-mode) (fast-screen-refresh (funcall tabbar-new-tab-function mode)) (new-frame-with-new-scratch one-buffer-one-frame mode))) (defun next-tab-or-buffer () "Call (tabbar-forward) if tabbar-mode is on; otherwise, call (next-buffer)." (interactive) (fast-screen-refresh (if (and (boundp tabbar-mode) tabbar-mode) (tabbar-forward) (next-buffer)))) (defun previous-tab-or-buffer () "Call (tabbar-forward) if tabbar-mode is on; otherwise, call (next-buffer)." (interactive) (fast-screen-refresh (if (and (boundp tabbar-mode) tabbar-mode) (tabbar-backward) (previous-buffer)))) ;;; Tabbar-Mwheel mode: redefine mwheel actions ; (defcustom tabbar-mwheel-mode-action nil "*Specify the behavior mouse wheel is used in tab bar. The following options are available: - `cycle-tabs' Mouse wheel down/up selects next/previous tab in window's tab set. - default Mouse wheel scrolls current buffer." :group 'tabbar :type '(choice :tag "Mouse wheel in tab bar..." (const :tag "Cycles through tabs" cycle-tabs) (const :tag "Scrolls current buffer" nil))) (defun tabbar-mwheel-up-action (event) (interactive "@e") (if tabbar-mwheel-mode-action (tabbar-mwheel-forward-tab event) (mwheel-scroll event))) (defun tabbar-mwheel-down-action (event) (interactive "@e") (if tabbar-mwheel-mode-action (tabbar-mwheel-backward-tab event) (mwheel-scroll event))) (if (get 'mouse-wheel 'event-symbol-elements) ;; Use one generic mouse wheel event (define-key tabbar-mwheel-mode-map [A-mouse-wheel] 'tabbar-mwheel-switch-tab) ;; Use separate up/down mouse wheel events (let ((up (tabbar--mwheel-key tabbar--mwheel-up-event)) (down (tabbar--mwheel-key tabbar--mwheel-down-event))) (define-key tabbar-mwheel-mode-map `[header-line ,down] 'tabbar-mwheel-down-action) (define-key tabbar-mwheel-mode-map `[header-line ,up] 'tabbar-mwheel-up-action) (define-key tabbar-mwheel-mode-map `[header-line (control ,down)] nil) (define-key tabbar-mwheel-mode-map `[header-line (control ,up)] nil) (define-key tabbar-mwheel-mode-map `[header-line (shift ,down)] nil) (define-key tabbar-mwheel-mode-map `[header-line (shift ,up)] nil))) (defun tabbar-order-tabs-by-file () (interactive) (tabbar-order-by-fun 'tabbar--order-by-buffer-path)) (defun tabbar-order-by-file-type () (interactive) (tabbar-order-by-fun 'tabbar--order-by-file-type)) (defun tabbar-reverse-tabs () (interactive) (tabbar-order-by-fun 'reverse)) (defun tabbar-order-by-fun (fun) (let* ((tabset (tabbar-current-tabset))) (setf (symbol-value tabset) (funcall fun (tabbar-tabs tabset)))) (tabbar-window-update-tabsets) ) (defun tabbar--order-by-buffer-path (list) (sort list (lambda (a b) (string-lessp (tabbar--path a) (tabbar--path b)))) ) (defun tabbar--order-by-file-type (list) (sort list (lambda (a b) (let* ((a (tabbar--path a)) (b (tabbar--path b)) (ae (file-name-extension a)) (be (file-name-extension b))) (if (string= ae be) (string-lessp a b) (string-lessp ae be)))) )) (defun tabbar--path (el) (let ((buffer (car el))) (buffer-file-name buffer))) ;; (symbol-value (tabbar-current-tabset)) ;; (tabbar-line-format (tabbar-get-tabset (number-to-string (window-number (selected-window))))) ;; (tabbar-tabs (tabbar-current-tabset)) ;; default tabbar behavior (buffer tabs grouped by major-mode) can be ;; retained by setting tabbar-inhibit-window-tabs to non-nil ;; (unless (and (boundp 'tabbar-inhibit-window-tabs) tabbar-inhibit-window-tabs) ;; ;; changes behavior of "buffer tabs", so that tabs are associated with a ;; ;; window instead of a major mode. ;; (require 'tabbar-window)) ;; will have to do a bit more work to make different tabbar styles work smoothly. ;; (i.e., no conditional loading of lisp!) ;; for now, stick with window tabs (condition-case nil (require 'tabbar-window) (error nil)) ;; start out with hidden window (add-hook 'after-init-hook (lambda () (if tabbar-mode (add-to-list 'header-line-inhibit-window-list (selected-window))) 'append)) (provide 'aquamacs-tabbar) tabbar-2.2/aquamacs-tools.el000066400000000000000000000513701332640313100160650ustar00rootroot00000000000000;; Aquamacs tools ;; some helper functions for Aquamacs ;; Author: David Reitter, david.reitter@gmail.com ;; Maintainer: David Reitter ;; Keywords: aquamacs ;; This file is part of Aquamacs Emacs ;; http://www.aquamacs.org/ ;; Aquamacs is free software; you can redistribute it and/or modify ;; it under the terms of the GNU General Public License as published by ;; the Free Software Foundation; either version 3, or (at your option) ;; any later version. ;; Aquamacs is distributed in the hope that it will be useful, ;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ;; GNU General Public License for more details. ;; You should have received a copy of the GNU General Public License ;; along with GNU Emacs; see the file COPYING. If not, write to the ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330, ;; Boston, MA 02111-1307, USA. ;; Copyright (C) 2005, 2007, 2009, 2013 David Reitter ; remove an element from an associative list (alist) ;; (defun remove-alist-name (name alist) ;; "Removes element whose car is NAME from ALIST." ;; (cond ((equal name (car (car alist))) ; found name ;; (cdr alist)) ;; ((null alist) ; end of list (termination cond) ;; nil) ;; (t ;; (cons (car alist) ; first of alist plus rest w/ recursion ;; (remove-alist-name name (cdr alist)))))) ;; this is assq ;; (defun get-alist-value-for-name (name alist) ;; "Returns value of element whose car is NAME from ALIST. nil if not found" ;; (cond ((equal name (car (car alist))) ; found name ;; (cdr (car alist))) ;; ((null alist) ; end of list (termination cond) ;; nil) ;; (t ;; ; first of alist plus rest w/ recursion ;; (get-alist-value-for-name name (cdr alist))))) ;; this is from cl-lib, which can't be included in site-load (defmacro cl-incf (place &optional x) "Increment PLACE by X (1 by default). PLACE may be a symbol, or any generalized variable allowed by `setf'. The return value is the incremented value of PLACE." (declare (debug (place &optional form))) (if (symbolp place) (list 'setq place (if x (list '+ place x) (list '1+ place))) (list 'cl-callf '+ place (or x 1)))) (defun running-on-a-mac-p () (memq initial-window-system '(mac ns))) (defun aquamacs-ask-for-confirmation (text long &optional yes-button no-button sheet) (let ((f (window-frame (minibuffer-window)))) (make-frame-visible f) (raise-frame f) ; make sure frame is visible (if (or (and last-nonmenu-event (not (consp last-nonmenu-event))) ;;(not (eq (car-safe last-nonmenu-event) ;; 'mac-apple-event))) (not use-dialog-box) (not window-system)) (progn ;; make sure the frame's minibuffer is actually visible ;; because minibuffer-setup-hook is not executed. (and (fboundp 'smart-move-minibuffer-inside-screen) smart-frame-positioning-mode (smart-move-minibuffer-inside-screen f)) (let ((text (if (string-match "\\(.*\\)\n" text) (match-string 1 text) text))) (if (and long (not aquamacs-quick-yes-or-no-prompt)) (old-yes-or-no-p text) (old-y-or-n-p text)))) (let ((ret (x-popup-dialog (or sheet (if (mouse-event-p last-command-event) last-command-event) `(mouse-1 (,(selected-window) 100 (0 . 50) -1))) (list text `(,(or yes-button "Yes") . t) `(,(or no-button "No") . nil))))) ret)))) (defun filter-list (lst elements) "Returns LST sans ELEMENTS. Creates a new list where all elements in ELEMENTS from LST are removed. Comparison is done with `eq'." (if (null lst) nil (if (member (car lst) elements) (filter-list (cdr lst) elements) (cons (car lst) (filter-list (cdr lst) elements))))) (defun assq-set-all (source dest-sym) "Writes all values from alist SOURCE into alist DEST-SYM, overwriting any previous associations in DEST" (mapc (lambda (x) (set dest-sym (assq-delete-all (car x) (eval dest-sym)))) source) (set dest-sym (append source (eval dest-sym)))) ; (setq test '((a . 1) (b . 2))) ; (assq-set-all '((b . 5) (c . 6)) 'test) ; (assq-subtract '((asd . 3) (wqe . 5)) '((wqq . 3) (wqe . 5))) ; (assq-subtract '((asd . 3) (wqe . 5)) '((wqq . 3) (wqe . 2))) ; (assq-subtract '((asd . 3) (wqe . 5)) '((wqq . 3) (wqe . 2)) t) (defun assq-subtract (a b &optional ignore-values) "Subtracts alist B from A. Order of elements is NOT preserved. If IGNORE-VALUES is non-nil, alist elements with differing cdrs (values) are still subtracted." (let ((ret)) (mapc (lambda (x) (let ((p (assq (car x) b))) (unless (and p (or ignore-values (eq (cdr p) (cdr x)))) (setq ret (cons x ret))))) a) ret)) (defun assq-set (key val alist) "Sets value associated with KEY to VAL in ALIST. ALIST must be a symbol giving the variable name. Comparison of keys is done with `eq'. New key-value pair will be in car of ALIST." (set alist (cons (cons key val) (assq-delete-all key (eval alist))))) (defun assq-set-equal (key val alist) "Sets value associated with the string KEY to VAL in ALIST. Comparison of keys is done with `equal'. ALIST must be a symbol giving the variable name. New key-value pair will be in car of ALIST." (set alist (cons (cons key val) (assq-delete-all-equal key (eval alist))))) (defun assq-string-equal (key alist) (loop for element in alist if (string-equal (car element) key) return element)) ;; (setq asd (list 1 2 3 4 5)) ;; (aq-replace-in-list asd 1 'a) ;; asd (defun aq-replace-in-list (list from to) (if (eq (car-safe list) from) (setcar list to)) (if (cdr-safe list) (aq-replace-in-list (cdr-safe list) from to))) (defun assq-delete-all-equal (key alist) "Delete from ALIST all elements whose car is `equal' to KEY. Return the modified alist. Elements of ALIST that are not conses are ignored." (while (and (consp (car alist)) (equal (car (car alist)) key)) (setq alist (cdr alist))) (let ((tail alist) tail-cdr) (while (setq tail-cdr (cdr tail)) (if (and (consp (car tail-cdr)) (equal (car (car tail-cdr)) key)) (setcdr tail (cdr tail-cdr)) (setq tail tail-cdr)))) alist) (defun aq-list-contains (list element) "Return non-nil if the LIST contains ELEMENT. Aquamacs only. Comparison is done with `eq'." (let (first result) (while list (if (not (eq (car-safe list) element)) (setq list (cdr-safe list)) (setq list nil) (setq result t)) ) result)) ;; (aq-list-contains (list 1 2 3 4 5 'a 'b nil 'x) 1) (defun aq-list-contains-equal (list element) "Return non-nil if the LIST contains ELEMENT. Aquamacs only. Comparison is done with `equal'." (let (first result) (while list (if (not (equal (car-safe list) element)) (setq list (cdr-safe list)) (setq list nil) (setq result t)) ) result)) (defun aq-chomp (str) "Chomp leading and tailing whitespace from STR." (let ((s (if (symbolp str) (symbol-name str) str))) (replace-regexp-in-string "\\(^[[:space:]\n]*\\|[[:space:]\n]*$\\)" "" s))) (defun fontset-exist-p (font) (condition-case nil (fontset-info font) (error nil)) ) ;; this needs to be replaced by functions defined earlier ; recursion is not so good in elisp anyways (defun filter-fonts (list) "Filters the font list LIST to contain only existing fontsets. Each element of LIST has to be of the form (symbol . fontset)." (mapcar (lambda (p) (mapcar (lambda (e) (if (and (consp e) (eq (car e) 'font) (not (fontset-exist-p (cdr e))) ) '(font . "fontset-standard") e)) p)) list)) (defun get-bufname (buf) (if (eq (type-of buf) 'string) buf (buffer-name buf)) ) (defun get-bufobj (buf) (if (eq (type-of buf) 'string) (get-buffer buf) buf) ) (defun find-all-windows-internal (buffer &optional onlyvis) "Find all windows that display a buffer." (let ((windows nil)) (walk-windows (lambda (wind) (if (eq (window-buffer wind) buffer) (push wind windows))) t (if onlyvis 'visible t)) windows ) ) ; (find-all-frames-internal (current-buffer)) (defun find-all-frames-internal (buffer &optional onlyvis) (let ((frames nil)) (walk-windows (lambda (wind) (if (eq (window-buffer wind) buffer) (let ((frm (window-frame wind))) (unless (memq frm frames) (push frm frames))))) nil (if onlyvis 'visible t)) frames)) (defgroup Aquamacs-is-more-than-Emacs nil "All defaults in Aquamacs that are different from GNU Emacs. This customization group contains every default for customization variables that is changed in Aquamacs compared to GNU Emacs 22 or an additionally included package. Note that non-customization variables as well as code may be changed or advised in Aquamacs (compared to GNU Emacs), so reverting all of these defaults to their GNU Emacs value will not give you a GNU Emacs. To achieve that, use a self-compiled binary of Carbon Emacs instead of Aquamacs." :group 'Aquamacs) (setq messages-buffer-max-lines 500) (defun aquamacs-set-defaults (list) "Set a new default for a customization option in Aquamacs. Add the value to the customization group `Aquamacs-is-more-than-Emacs'." (mapc (lambda (elt) (custom-load-symbol (car elt)) ;; does nothing for non-custom variables (let* ((symbol (car elt)) ;; we're accessing the doc property here so ;; if the symbol is an autoload symbol, ;; it'll get loaded now before setting its defaults ;; (e.g. standard-value), which would otherwise be ;; overwritten. (old-doc (condition-case nil (documentation-property symbol 'variable-documentation) (error ""))) (value (car (cdr elt))) (s-value (get symbol 'standard-value)) (setter (get symbol 'custom-set))) ;; if there's a setter, use it ;; note: symbol must be loaded for this to work (if setter ;; if customizable and there is a special setter (funcall setter symbol value) ;; otherwise, just set it (set symbol value)) (set-default symbol value) ;; new in post-0.9.5 ;; To Do: consider calling `custom-theme-set-variables' for custom ;; settings and create an Aquamacs theme. This is not trivial, ;; as we do not want to store a "saved variable" as opposed to a ;; new default (as if it had been set with `defcustom'). ;; make sure that user customizations get ;; saved to customizations.el (.emacs) ;; and that this appears as the new default. ;; since the standard-value changed, put it in the ;; group (put symbol 'standard-value `((quote ,(copy-tree (eval symbol))))) (unless (or (eq s-value (get symbol 'standard-value)) (get symbol 'aquamacs-original-default)) (put symbol 'aquamacs-original-default s-value) (if old-doc ;; in some cases the documentation ;; might not be loaded. Can we load it somehow? ;; either way, the "if" is a workaround. (put symbol 'variable-documentation (concat old-doc (format " The original default (in GNU Emacs or in the package) was: %s" s-value)))) (custom-add-to-group 'Aquamacs-is-more-than-Emacs symbol 'custom-variable)))) list)) ; (aquamacs-setup) (defun url-encode-string (string &optional coding) "Encode STRING by url-encoding. Optional CODING is used for encoding coding-system." (apply (function concat) (mapcar (lambda (ch) (cond ((eq ch ?\n) ; newline "%0D%0A") ((string-match "[-a-zA-Z0-9_:/.]" (char-to-string ch)) (char-to-string ch)) ; printable ((char-equal ch ?\x20) ; space "%20") (t (format "%%%02x" ch)))) ; escape ;; Coerce a string to a list of chars. (append (encode-coding-string (or string "") (or coding file-name-coding-system)) nil)))) (defun load-post-sitestart-files () "Load the Aquamacs plugins from site-start directories." (let (loaded) (mapc (lambda (p) (unless (file-exists-p (concat p "/.ignore")) (let ((infod (concat p "/info")) (file (expand-file-name (concat p "/site-start") "~/"))) (unless (member file loaded) (if (file-directory-p infod) (add-to-list 'Info-default-directory-list infod)) (if (and debug-on-error ;; [too slow if always on] (file-expand-wildcards (concat file ".*")) t) (message "loading post-sitestart %s." file)) (load file 'noerror) (setq loaded (cons file loaded)))))) load-path) t)) ; (measure-time (load-post-sitestart-files)) (defun load-pre-sitestart-files () "Load the pre-start Aquamacs plugins from site-prestart directories." (let (loaded) (mapc (lambda (p) (unless (file-exists-p (concat p "/.ignore")) (let ((infod (concat p "/info")) (file (expand-file-name (concat p "/site-prestart") "~/"))) (unless (member file loaded) (if (file-directory-p infod) (add-to-list 'Info-default-directory-list infod)) (if (and debug-on-error ;; [too slow if always on] (file-expand-wildcards (concat file ".*")) [too slow]) (message "loading pre-sitestart %s." file)) (load file 'noerror) (setq loaded (cons file loaded)))))) load-path) t)) ; (load-pre-sitestart-files) (defvar aq-timer nil) (defun aq-current-milliseconds () (let ((ti (cdr (current-time))) ) (+ (* 1000 (- (car ti) (car (cdr aq-timer)))) (/ (- (car (cdr ti)) (car (cdr (cdr aq-timer))) ) 1000)))) (defun aq-start-timer () (setq aq-timer (current-time)) ) ;(aq-start-timer) (defun aq-print-timer () (message (format "%d" (aq-current-milliseconds)) )) (defun aquamacs-pretty-mode-name (mode) (capitalize (replace-regexp-in-string "-mode" "" (symbol-name mode)))) ;; apple command character is unicode x2318 ;; (aq-describe-modifier 'hyper) (defun aq-describe-modifier (mod) ;; translate modifier (if (eq mod 'ctrl) (setq mod 'control)) (or (cond ((and (boundp 'mac-command-modifier) (eq mac-command-modifier mod)) (string (decode-char 'ucs #X2318))) ((and (boundp 'mac-option-modifier) (eq (or mac-option-modifier 'alt) mod)) (string (decode-char 'ucs #X2325))) ((and (boundp 'mac-control-modifier) (eq (or mac-control-modifier 'control) mod)) (string (decode-char 'ucs #X2303))) ((eq mod 'shift) (string (decode-char 'ucs #X21E7))) ((and (boundp 'mac-function-modifier) (eq mac-function-modifier mod)) "Fn ") ) ;; (progn (print mod) nil) (signal 'search-failed nil) )) (defvar apple-char (string (decode-char 'ucs #X2318))) ;; The following is a big hack. The mac port can't currently cope ;; with putting the command key combos in the menu, for various ;; reasons (1. they are just secondary alternatives, 2. command is defined ;; as 'alt' and only known as such) ; redefine New ; (define-key menu-bar-edit-menu [mark-whole-buffer] (cdr (assq 'mark-whole-buffer (key-binding [menu-bar edit])))) (defun get-window-for-other-buffer (&optional dont-make-frame buffer) "Find a suitable window for other buffers. Preferably the selected one. If a frame is created for the other buffer, show BUFFER in that frame." (let ((sel-win (selected-window))) ; search all visible&iconified frames (unless (and sel-win (window-live-p sel-win) (eq t (frame-visible-p (window-frame sel-win))) (not (special-display-p (or (buffer-name (window-buffer sel-win)) "")))) ;; search visible frames (but not dedicated ones) (setq sel-win (get-largest-window 'visible nil))) (unless (and sel-win (window-live-p sel-win) (eq t (frame-visible-p (window-frame sel-win))) (not (special-display-p (or (buffer-name (window-buffer sel-win)) "")))) (unless dont-make-frame (setq sel-win (frame-first-window (with-current-buffer (or buffer (current-buffer)) ;; make sure we're not creating some "special" frame (make-frame)))))) (if sel-win (unless (eq t (frame-visible-p (window-frame sel-win))) (make-frame-visible (window-frame sel-win)))) sel-win)) ;; New documents (defun new-empty-buffer-other-frame (&optional mode) "Opens a new frame containing an empty buffer." (interactive) (new-empty-buffer t mode)) (defcustom aquamacs-default-major-mode 'text-mode "Major mode in effect when new empty buffers are created. Specifies the major mode to be used for `new-empty-buffer' and `new-empty-buffer-other-frame'." :group 'Aquamacs) (defvar aquamacs--new-buffer-last-timestamp nil) (defvar aquamacs--new-buffer-timestamp-counter 0) (defun new-empty-buffer (&optional other-frame mode) "Visits an empty buffer. The major mode is set to MODE, or, if that is nil, the value of `aquamacs-default-major-mode'." (interactive) (let ((buf (generate-new-buffer (mac-new-buffer-name "untitled")))) ;; setting mode is done before showing the new frame ;; because otherwise, we get a nasty animation effect (save-excursion (set-buffer buf) (funcall (or mode aquamacs-default-major-mode (default-value 'major-mode) 'ignore))) (if other-frame (switch-to-buffer-other-frame buf) (let ((one-buffer-one-frame-force one-buffer-one-frame-mode)) ;; change window in case its unsuitable (dedicated or special display) (select-window (get-window-for-other-buffer)) ;; force new frame (switch-to-buffer buf) (select-frame-set-input-focus (window-frame (selected-window))))) (setq buffer-offer-save t) (put 'buffer-offer-save 'permanent-local t) (let* ((ts (format-time-string "%d%H%MZ" nil t)) (ts2 ts)) (if (equal ts2 aquamacs--new-buffer-last-timestamp) (setq ts2 (format "%s.%s" ts (cl-incf aquamacs--new-buffer-timestamp-counter))) (setq aquamacs--new-buffer-timestamp-counter 0)) (setq aquamacs--new-buffer-last-timestamp ts) (setq aquamacs-untitled-buffer-creation-time ts2)) (if auto-save-default (auto-save-mode t)) (set-buffer-modified-p nil))) (defalias 'new-frame-with-new-scratch 'new-empty-buffer) ;; auto save purging (defun purge-session-and-auto-save-files (&optional days) "Deletes old auto-save files and session files. If given, DAYS indicates the number of days to keep such files. Otherwise, a sensible default is assumed. Files may be moved to the trash or deleted. Aquamacs only. " (interactive) (let* ((days (or days 31)) (count1 (aquamacs-purge-directory (file-name-directory auto-save-list-file-prefix) (concat "\\`" (regexp-quote (file-name-nondirectory auto-save-list-file-prefix))) days)) (count2 (aquamacs-purge-directory (file-name-directory aquamacs-autosave-directory) ".*" days))) (if (called-interactively-p 'interactive) (message "%s Session and %s Auto save files older than %s days purged." count1 count2 days)))) (defun aquamacs-purge-directory (directory regexp days) "Delete old files from directory" (condition-case nil (let* ((count 0) (cutoff-time (- (car (current-time)) (/ (* days 24) 18)))) ; that's about a week (mapc (lambda (file) (when (and (< (car (nth 5 (file-attributes file))) cutoff-time) (not (file-directory-p file))) (move-file-to-trash file) (setq count (1+ count)))) (directory-files (expand-file-name directory) t regexp t)) count) (error 0))) (defun list2english (list &optional avoid-oxford-comma add-be) "Converts a list of strings to a single string with an English-language list. Commas and \"and\" are inserted as necessary An Oxford comma is used by default if appropriate. Set AVOID-OXFORD-COMMA to non-nil to prevent an Oxford comma in any case." (concat (list2english-internal list (if avoid-oxford-comma 'avoid)) (if add-be (if (or (not list) (cdr list)) " are" " is") ""))) (defun list2english-internal (list &optional avoid-oxford-comma) (if (cddr list) (list2english-internal (cons (concat (car list) ", " (cadr list)) (cddr list)) (or avoid-oxford-comma 'force-on)) (if (cdr list) (concat (car list) (if (equal avoid-oxford-comma 'force-on) ", and " " and ") (cadr list)) (car list)))) ;; test cases ;; (list2english '("one" "two")) ;; (list2english '("one" "two" "three") nil nil) ;; (list2english '("one" "two" "three") t t) ;; (list2english '("one")) ;; (list2english '("one") t t) ;; (list2english '("one") nil t) ;; (list2english '("one" "two" "three") 'no) ;; (list2english nil nil t) (defun login-shell-command-to-string (command) "Execute login shell command COMMAND and return its output as a string." (with-output-to-string (with-current-buffer standard-output (process-file shell-file-name nil t nil "-l" shell-command-switch command)))) (provide 'aquamacs-tools) tabbar-2.2/close-tab.tiff000066400000000000000000000167021332640313100153350ustar00rootroot00000000000000II*xMjQEˢ`!Fja!`3V"*B4AY٧)U4OS0kBE$C#1.05ȇٲRF ~֕l2cfiێ=K Nh–Jez5: /a9SMs@F:߆R/Tb4".0PI6y72Q     ()=RsH (:close-tab.tiffCreated with GIMPR8$R8$ HLinomntrRGB XYZ  1acspMSFTIEC sRGB-HP cprtP3desclwtptbkptrXYZgXYZ,bXYZ@dmndTpdmddvuedLview$lumimeas $tech0 rTRC< gTRC< bTRC< textCopyright (c) 1998 Hewlett-Packard CompanydescsRGB IEC61966-2.1sRGB IEC61966-2.1XYZ QXYZ XYZ o8XYZ bXYZ $descIEC http://www.iec.chIEC http://www.iec.chdesc.IEC 61966-2.1 Default RGB colour space - sRGB.IEC 61966-2.1 Default RGB colour space - sRGBdesc,Reference Viewing Condition in IEC61966-2.1,Reference Viewing Condition in IEC61966-2.1view_. \XYZ L VPWmeassig CRT curv #(-27;@EJOTY^chmrw| %+28>ELRY`gnu| &/8AKT]gqz !-8COZfr~ -;HUcq~ +:IXgw'7HYj{+=Oat 2FZn  % : O d y  ' = T j " 9 Q i  * C \ u & @ Z t .Id %A^z &Ca~1Om&Ed#Cc'Ij4Vx&IlAe@e Ek*Qw;c*R{Gp@j>i  A l !!H!u!!!"'"U"""# #8#f###$$M$|$$% %8%h%%%&'&W&&&''I'z''( (?(q(())8)k))**5*h**++6+i++,,9,n,,- -A-v--..L.../$/Z///050l0011J1112*2c223 3F3334+4e4455M555676r667$7`7788P8899B999:6:t::;-;k;;<' >`>>?!?a??@#@d@@A)AjAAB0BrBBC:C}CDDGDDEEUEEF"FgFFG5G{GHHKHHIIcIIJ7J}JK KSKKL*LrLMMJMMN%NnNOOIOOP'PqPQQPQQR1R|RSS_SSTBTTU(UuUVV\VVWDWWX/X}XYYiYZZVZZ[E[[\5\\]']x]^^l^__a_``W``aOaabIbbcCccd@dde=eef=ffg=ggh?hhiCiijHjjkOkklWlmm`mnnknooxop+ppq:qqrKrss]sttptu(uuv>vvwVwxxnxy*yyzFz{{c{|!||}A}~~b~#G k͂0WGrׇ;iΉ3dʋ0cʍ1fΏ6n֑?zM _ɖ4 uL$h՛BdҞ@iءG&vVǥ8nRĩ7u\ЭD-u`ֲK³8%yhYѹJº;.! zpg_XQKFAǿ=ȼ:ɹ8ʷ6˶5̵5͵6ζ7ϸ9к<Ѿ?DINU\dlvۀ܊ݖޢ)߯6DScs 2F[p(@Xr4Pm8Ww)KmxڝTNA=K V >!6Ggha[a 0Y'`M! >;H4؈̲ˢ S޹3gs\ hHc  /; J||Epkr'})}l /;0cȃq]<714|Q4E߅SbHDp-c Oxv"*-bM\.rELRY`gnu| &/8AKT]gqz !-8COZfr~ -;HUcq~ +:IXgw'7HYj{+=Oat 2FZn  % : O d y  ' = T j " 9 Q i  * C \ u & @ Z t .Id %A^z &Ca~1Om&Ed#Cc'Ij4Vx&IlAe@e Ek*Qw;c*R{Gp@j>i  A l !!H!u!!!"'"U"""# #8#f###$$M$|$$% %8%h%%%&'&W&&&''I'z''( (?(q(())8)k))**5*h**++6+i++,,9,n,,- -A-v--..L.../$/Z///050l0011J1112*2c223 3F3334+4e4455M555676r667$7`7788P8899B999:6:t::;-;k;;<' >`>>?!?a??@#@d@@A)AjAAB0BrBBC:C}CDDGDDEEUEEF"FgFFG5G{GHHKHHIIcIIJ7J}JK KSKKL*LrLMMJMMN%NnNOOIOOP'PqPQQPQQR1R|RSS_SSTBTTU(UuUVV\VVWDWWX/X}XYYiYZZVZZ[E[[\5\\]']x]^^l^__a_``W``aOaabIbbcCccd@dde=eef=ffg=ggh?hhiCiijHjjkOkklWlmm`mnnknooxop+ppq:qqrKrss]sttptu(uuv>vvwVwxxnxy*yyzFz{{c{|!||}A}~~b~#G k͂0WGrׇ;iΉ3dʋ0cʍ1fΏ6n֑?zM _ɖ4 uL$h՛BdҞ@iءG&vVǥ8nRĩ7u\ЭD-u`ֲK³8%yhYѹJº;.! zpg_XQKFAǿ=ȼ:ɹ8ʷ6˶5̵5͵6ζ7ϸ9к<Ѿ?DINU\dlvۀ܊ݖޢ)߯6DScs 2F[p(@Xr4Pm8Ww)Kmtabbar-2.2/down.png000066400000000000000000000002721332640313100142620ustar00rootroot00000000000000PNG  IHDR;mGIDAT8!@E_3` iրXqlTGR6Hp̟ɛ?u>r(4f .IJo7ОHζ/I˕$02I;/)IENDB`tabbar-2.2/left.tiff000066400000000000000000000156241332640313100144200ustar00rootroot00000000000000II*:xc`j`:C(CjV9ut8aLFla|R O    HR1dl()=RsH tleft.tiffCreated with GIMPYY HLinomntrRGB XYZ  1acspMSFTIEC sRGB-HP cprtP3desclwtptbkptrXYZgXYZ,bXYZ@dmndTpdmddvuedLview$lumimeas $tech0 rTRC< gTRC< bTRC< textCopyright (c) 1998 Hewlett-Packard CompanydescsRGB IEC61966-2.1sRGB IEC61966-2.1XYZ QXYZ XYZ o8XYZ bXYZ $descIEC http://www.iec.chIEC http://www.iec.chdesc.IEC 61966-2.1 Default RGB colour space - sRGB.IEC 61966-2.1 Default RGB colour space - sRGBdesc,Reference Viewing Condition in IEC61966-2.1,Reference Viewing Condition in IEC61966-2.1view_. \XYZ L VPWmeassig CRT curv #(-27;@EJOTY^chmrw| %+28>ELRY`gnu| &/8AKT]gqz !-8COZfr~ -;HUcq~ +:IXgw'7HYj{+=Oat 2FZn  % : O d y  ' = T j " 9 Q i  * C \ u & @ Z t .Id %A^z &Ca~1Om&Ed#Cc'Ij4Vx&IlAe@e Ek*Qw;c*R{Gp@j>i  A l !!H!u!!!"'"U"""# #8#f###$$M$|$$% %8%h%%%&'&W&&&''I'z''( (?(q(())8)k))**5*h**++6+i++,,9,n,,- -A-v--..L.../$/Z///050l0011J1112*2c223 3F3334+4e4455M555676r667$7`7788P8899B999:6:t::;-;k;;<' >`>>?!?a??@#@d@@A)AjAAB0BrBBC:C}CDDGDDEEUEEF"FgFFG5G{GHHKHHIIcIIJ7J}JK KSKKL*LrLMMJMMN%NnNOOIOOP'PqPQQPQQR1R|RSS_SSTBTTU(UuUVV\VVWDWWX/X}XYYiYZZVZZ[E[[\5\\]']x]^^l^__a_``W``aOaabIbbcCccd@dde=eef=ffg=ggh?hhiCiijHjjkOkklWlmm`mnnknooxop+ppq:qqrKrss]sttptu(uuv>vvwVwxxnxy*yyzFz{{c{|!||}A}~~b~#G k͂0WGrׇ;iΉ3dʋ0cʍ1fΏ6n֑?zM _ɖ4 uL$h՛BdҞ@iءG&vVǥ8nRĩ7u\ЭD-u`ֲK³8%yhYѹJº;.! zpg_XQKFAǿ=ȼ:ɹ8ʷ6˶5̵5͵6ζ7ϸ9к<Ѿ?DINU\dlvۀ܊ݖޢ)߯6DScs 2F[p(@Xr4Pm8Ww)Kmxc``(L ~ddfHag`d$V_[8趒O~]B~t(     *  V<D()=RsH Lleft.tiffCreated with GIMPYY HLinomntrRGB XYZ  1acspMSFTIEC sRGB-HP cprtP3desclwtptbkptrXYZgXYZ,bXYZ@dmndTpdmddvuedLview$lumimeas $tech0 rTRC< gTRC< bTRC< textCopyright (c) 1998 Hewlett-Packard CompanydescsRGB IEC61966-2.1sRGB IEC61966-2.1XYZ QXYZ XYZ o8XYZ bXYZ $descIEC http://www.iec.chIEC http://www.iec.chdesc.IEC 61966-2.1 Default RGB colour space - sRGB.IEC 61966-2.1 Default RGB colour space - sRGBdesc,Reference Viewing Condition in IEC61966-2.1,Reference Viewing Condition in IEC61966-2.1view_. \XYZ L VPWmeassig CRT curv #(-27;@EJOTY^chmrw| %+28>ELRY`gnu| &/8AKT]gqz !-8COZfr~ -;HUcq~ +:IXgw'7HYj{+=Oat 2FZn  % : O d y  ' = T j " 9 Q i  * C \ u & @ Z t .Id %A^z &Ca~1Om&Ed#Cc'Ij4Vx&IlAe@e Ek*Qw;c*R{Gp@j>i  A l !!H!u!!!"'"U"""# #8#f###$$M$|$$% %8%h%%%&'&W&&&''I'z''( (?(q(())8)k))**5*h**++6+i++,,9,n,,- -A-v--..L.../$/Z///050l0011J1112*2c223 3F3334+4e4455M555676r667$7`7788P8899B999:6:t::;-;k;;<' >`>>?!?a??@#@d@@A)AjAAB0BrBBC:C}CDDGDDEEUEEF"FgFFG5G{GHHKHHIIcIIJ7J}JK KSKKL*LrLMMJMMN%NnNOOIOOP'PqPQQPQQR1R|RSS_SSTBTTU(UuUVV\VVWDWWX/X}XYYiYZZVZZ[E[[\5\\]']x]^^l^__a_``W``aOaabIbbcCccd@dde=eef=ffg=ggh?hhiCiijHjjkOkklWlmm`mnnknooxop+ppq:qqrKrss]sttptu(uuv>vvwVwxxnxy*yyzFz{{c{|!||}A}~~b~#G k͂0WGrׇ;iΉ3dʋ0cʍ1fΏ6n֑?zM _ɖ4 uL$h՛BdҞ@iءG&vVǥ8nRĩ7u\ЭD-u`ֲK³8%yhYѹJº;.! zpg_XQKFAǿ=ȼ:ɹ8ʷ6˶5̵5͵6ζ7ϸ9к<Ѿ?DINU\dlvۀ܊ݖޢ)߯6DScs 2F[p(@Xr4Pm8Ww)Kmtabbar-2.2/left_disabled.tiff000066400000000000000000000157121332640313100162450ustar00rootroot00000000000000II*:xc`j` C(CV9ut8aFla|R O   H\1nv()=RsH ~>left_disabled.tiffCreated with GIMPYY HLinomntrRGB XYZ  1acspMSFTIEC sRGB-HP cprtP3desclwtptbkptrXYZgXYZ,bXYZ@dmndTpdmddvuedLview$lumimeas $tech0 rTRC< gTRC< bTRC< textCopyright (c) 1998 Hewlett-Packard CompanydescsRGB IEC61966-2.1sRGB IEC61966-2.1XYZ QXYZ XYZ o8XYZ bXYZ $descIEC http://www.iec.chIEC http://www.iec.chdesc.IEC 61966-2.1 Default RGB colour space - sRGB.IEC 61966-2.1 Default RGB colour space - sRGBdesc,Reference Viewing Condition in IEC61966-2.1,Reference Viewing Condition in IEC61966-2.1view_. \XYZ L VPWmeassig CRT curv #(-27;@EJOTY^chmrw| %+28>ELRY`gnu| &/8AKT]gqz !-8COZfr~ -;HUcq~ +:IXgw'7HYj{+=Oat 2FZn  % : O d y  ' = T j " 9 Q i  * C \ u & @ Z t .Id %A^z &Ca~1Om&Ed#Cc'Ij4Vx&IlAe@e Ek*Qw;c*R{Gp@j>i  A l !!H!u!!!"'"U"""# #8#f###$$M$|$$% %8%h%%%&'&W&&&''I'z''( (?(q(())8)k))**5*h**++6+i++,,9,n,,- -A-v--..L.../$/Z///050l0011J1112*2c223 3F3334+4e4455M555676r667$7`7788P8899B999:6:t::;-;k;;<' >`>>?!?a??@#@d@@A)AjAAB0BrBBC:C}CDDGDDEEUEEF"FgFFG5G{GHHKHHIIcIIJ7J}JK KSKKL*LrLMMJMMN%NnNOOIOOP'PqPQQPQQR1R|RSS_SSTBTTU(UuUVV\VVWDWWX/X}XYYiYZZVZZ[E[[\5\\]']x]^^l^__a_``W``aOaabIbbcCccd@dde=eef=ffg=ggh?hhiCiijHjjkOkklWlmm`mnnknooxop+ppq:qqrKrss]sttptu(uuv>vvwVwxxnxy*yyzFz{{c{|!||}A}~~b~#G k͂0WGrׇ;iΉ3dʋ0cʍ1fΏ6n֑?zM _ɖ4 uL$h՛BdҞ@iءG&vVǥ8nRĩ7u\ЭD-u`ֲK³8%yhYѹJº;.! zpg_XQKFAǿ=ȼ:ɹ8ʷ6˶5̵5͵6ζ7ϸ9к<Ѿ?DINU\dlvۀ܊ݖޢ)߯6DScs 2F[p(@Xr4Pm8Ww)Kmxc`~` rn`!U ڗt[J !V?q3T/I%OQLie 3pt.!W?%=d_$Q)    L`  wrz()=RsH left_disabled.tiffCreated with GIMPYY HLinomntrRGB XYZ  1acspMSFTIEC sRGB-HP cprtP3desclwtptbkptrXYZgXYZ,bXYZ@dmndTpdmddvuedLview$lumimeas $tech0 rTRC< gTRC< bTRC< textCopyright (c) 1998 Hewlett-Packard CompanydescsRGB IEC61966-2.1sRGB IEC61966-2.1XYZ QXYZ XYZ o8XYZ bXYZ $descIEC http://www.iec.chIEC http://www.iec.chdesc.IEC 61966-2.1 Default RGB colour space - sRGB.IEC 61966-2.1 Default RGB colour space - sRGBdesc,Reference Viewing Condition in IEC61966-2.1,Reference Viewing Condition in IEC61966-2.1view_. \XYZ L VPWmeassig CRT curv #(-27;@EJOTY^chmrw| %+28>ELRY`gnu| &/8AKT]gqz !-8COZfr~ -;HUcq~ +:IXgw'7HYj{+=Oat 2FZn  % : O d y  ' = T j " 9 Q i  * C \ u & @ Z t .Id %A^z &Ca~1Om&Ed#Cc'Ij4Vx&IlAe@e Ek*Qw;c*R{Gp@j>i  A l !!H!u!!!"'"U"""# #8#f###$$M$|$$% %8%h%%%&'&W&&&''I'z''( (?(q(())8)k))**5*h**++6+i++,,9,n,,- -A-v--..L.../$/Z///050l0011J1112*2c223 3F3334+4e4455M555676r667$7`7788P8899B999:6:t::;-;k;;<' >`>>?!?a??@#@d@@A)AjAAB0BrBBC:C}CDDGDDEEUEEF"FgFFG5G{GHHKHHIIcIIJ7J}JK KSKKL*LrLMMJMMN%NnNOOIOOP'PqPQQPQQR1R|RSS_SSTBTTU(UuUVV\VVWDWWX/X}XYYiYZZVZZ[E[[\5\\]']x]^^l^__a_``W``aOaabIbbcCccd@dde=eef=ffg=ggh?hhiCiijHjjkOkklWlmm`mnnknooxop+ppq:qqrKrss]sttptu(uuv>vvwVwxxnxy*yyzFz{{c{|!||}A}~~b~#G k͂0WGrׇ;iΉ3dʋ0cʍ1fΏ6n֑?zM _ɖ4 uL$h՛BdҞ@iءG&vVǥ8nRĩ7u\ЭD-u`ֲK³8%yhYѹJº;.! zpg_XQKFAǿ=ȼ:ɹ8ʷ6˶5̵5͵6ζ7ϸ9к<Ѿ?DINU\dlvۀ܊ݖޢ)߯6DScs 2F[p(@Xr4Pm8Ww)Kmtabbar-2.2/one-buffer-one-frame.el000066400000000000000000001216461332640313100170370ustar00rootroot00000000000000;; one-buffer-one-frame.el ;; Frame/buffer/window management in Aquamacs including `one-buffer-one-frame-mode' ;; ;; Author: David Reitter, david.reitter@gmail.com ;; Maintainer: David Reitter ;; Keywords: aquamacs ;; This file is part of Aquamacs Emacs ;; http://aquamacs.org/ ;; Aquamacs is free software; you can redistribute it and/or modify ;; it under the terms of the GNU General Public License as published by ;; the Free Software Foundation; either version 3, or (at your option) ;; any later version. ;; Aquamacs is distributed in the hope that it will be useful, ;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ;; GNU General Public License for more details. ;; You should have received a copy of the GNU General Public License ;; along with Aquamacs; see the file COPYING. If not, write to the ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330, ;; Boston, MA 02111-1307, USA. ;; Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2012, 2013, 2014 David Reitter ;; DESCRIPTION: ;; ;; Always open new frames for each new buffer and switch to their frame. ;; In this minor mode, buffers are usually displayed in their own frames. ;; All buffer switching functions available to users will raise the ;; frame that shows the buffer. Deletion of the frame (or window) usually ;; kills the associated buffer, unless the buffer is still shown in another ;; window or it is a special-purpose buffer such as `*Messages*'. ;; ;; To enable, add this to your init file: ;; (one-buffer-one-frame-mode t) ;; KNOWN ISSUES ;; save-window-excursion does not unwind newly created frames. ;; because we advise switch-to-buffer to open stuff in new frames, ;; we get undesirable behavior, for example in viper-mode, where ;; an extra frame is opened. ;; it might make sense to extend save-window-excursion... ;; doesn't play well with ediff-directories ;; conjecture: ediff divides the frame (into two windows), then calls switch-to-buffer ;; instead of using pop-to-buffer (require 'aquamacs-tools) (defvar one-buffer-one-frame-mode-map (make-sparse-keymap)) (defvar obof-backups-initialized nil) (define-minor-mode one-buffer-one-frame-mode "Always open new frames for each new buffer and switch to their frame. In this minor mode, buffers are usually displayed in their own frames. All buffer switching functions available to users will raise the frame that shows the buffer. Deletion of the frame (or window) usually kills the associated buffer, unless the buffer is still shown in another window or it is a special-purpose buffer such as `*Messages*'. This minor mode provides some additional key bindings: C-x B `switch-to-buffer-here' C-x S-left `previous-buffer-here' C-x S-right `next-buffer-here' C-x C-B `list-buffers-here' Decisions about showing buffers in separate frames can be influenced in a number of customization variables. Buffers are, by default, shown in new frames, unless they are switched to with `switch-to-buffer' and match an entry in `obof-same-frame-switching-regexps', or they are popped up with `pop-to-buffer' and match an entry in `obof-same-frame-regexps' \(typically Emacs always shows these in a new window). A matching entry in `obof-other-frame-regexps' will always force buffers to be shown in a new frame. The mode sets `pop-up-frames', `pop-up-windows', `display-buffer-reuse-frames'. This mode is part of Aquamacs Emacs, http://aquamacs.org." :group 'Aquamacs :global t :keymap 'one-buffer-one-frame-mode-map :require 'aquamacs-frame-setup (if (running-on-a-mac-p) (progn (if one-buffer-one-frame-mode (setq obofm-old-pop-up-frames pop-up-frames pop-up-frames nil ;; if pop-up-frames is t, even *Completions* buffers ;; will spawn their own frames obofm-old-pop-up-windows pop-up-windows ;; if this is set to t, we ignore the user's preferenes ;; and it doesn't lead to good decisions (by default) ;; pop-up-windows t obofm-old-display-buffer-reuse-frames display-buffer-reuse-frames display-buffer-reuse-frames t obof-backups-initialized t ;; pressing q in a view should delete the frame view-remove-frame-by-deleting t) ; else (turning off) ;; restore settings (if obof-backups-initialized (setq pop-up-frames obofm-old-pop-up-frames ;; pop-up-windows obofm-old-pop-up-windows display-buffer-reuse-frames obofm-old-display-buffer-reuse-frames))) (message "one-buffer-one-frame-mode %sabled." (if one-buffer-one-frame-mode "en" "dis"))) ;; no window-system available (message "one-buffer-one-frame mode won't work without frames."))) ;; because of the following alias, setting the mode variable will ;; enable most of the mode, but not the keymap. (defvaralias 'one-buffer-one-frame 'one-buffer-one-frame-mode) (defun enable-one-buffer-one-frame-mode () "Turn on `one-buffer-one-frame-mode' if `one-buffer-one-frame' is non-nil. This ensures that the mode is active even if one-buffer-one-frame is set with `setq' in the user's init file. This is just a kludge. To enable `one-buffer-one-frame-mode', call (one-buffer-one-frame-mode 1) To disable `one-buffer-one-frame-mode', call (one-buffer-one-frame-mode 0)" (one-buffer-one-frame-mode (if one-buffer-one-frame 1 0))) (defvar one-buffer-one-frame-force nil "Enforce one-buffer-one-frame - should be set only temporarily.") (defvar one-buffer-one-frame-inhibit nil "Enforce one-buffer-one-frame - should be set only temporarily.") (defcustom obof-same-window-buffer-names nil "Like `same-window-buffer-names', but for `one-buffer-one-frame-mode'. This may be a list of names of buffers to be shown in the same window, as in `same-window-buffer-names'. It may also be set to the symbol `same-window-buffer-names', in which case the value of `same-window-buffer-names' is used." :group 'Aquamacs :group 'frames) (defcustom obof-same-window-regexps nil "Like `same-window-regexps', but for `one-buffer-one-frame-mode'. This may be a list of regexps applying to names of buffers to be shown in the same window, as in `same-window-regexps'. It may also be set to the symbol `same-window-regexps', in which case the value of `same-window-regexps' is used." :group 'Aquamacs :group 'frames) (defcustom obof-same-frame-regexps '( " SPEEDBAR" "\\*.*\\*") "Buffers popped up in a new window in `one-buffer-one-frame-mode'. In `one-buffer-one-frame-mode', if the name of a buffer to be shown matches one of the regular expressions in this list, it is shown in the same frame, when shown with `pop-to-buffer' (or `display-buffer' in general). A new window inside the frame may be opened to show the buffer. Exceptions are listed in `obof-other-frame-regexps'." :group 'Aquamacs :group 'frames) (defcustom obof-same-frame-switching-regexps '( " SPEEDBAR" "*About GNU Emacs*") "Buffers to switch to in the same frame in `one-buffer-one-frame-mode'. In `one-buffer-one-frame-mode', if the name of a buffer to be shown matches one of the regular expressions in this list, it is shown in the same frame when switched to with `switch-to-buffer'. Exceptions are listed in `obof-other-frame-regexps'." :group 'Aquamacs :group 'frames) (defcustom obof-other-frame-regexps '( "\\*Messages\\*" "\\*scratch\\*" "\\*Help\\*" "\\*Custom.*\\*" ".*output\\*" "\\*mail\\*" "\\*grep\\*" "\\*shell\\*" "\\*Faces\\*" "\\*Colors\\*") "Buffers always shown in a separate frame in `one-buffer-one-frame-mode'. In `one-buffer-one-frame-mode', if the name of a buffer to be shown matches one of the regular expressions in this list, it is shown in a separate frame. This overrides entries in `obof-same-frame-regexps'." :group 'Aquamacs :group 'frames) (defun obof-same-frame-p (buf &optional switching) (let ((from-buf (and last-command-event (listp (event-start last-command-event)) (let ((clicked-in-window (posn-window (event-start last-command-event)))) (and (window-live-p clicked-in-window) (window-buffer clicked-in-window)))))) (with-current-buffer (or from-buf (current-buffer)) (or (not one-buffer-one-frame-mode) (let ( (bufname (get-bufname buf))) (if one-buffer-one-frame-force ;; set by color-theme nil (or ;; when called, the current buffer is already the new buffer ;; so check the event one-buffer-one-frame-inhibit (and (or (= (buffer-size (window-buffer)) 0) (let ((same-window-buffer-names nil) (same-window-regexps (if switching obof-same-frame-switching-regexps obof-same-frame-regexps))) ;; this is a fast solution (same-window-p bufname))) (not (let ((same-window-buffer-names nil) (same-window-regexps obof-other-frame-regexps)) ;; this is a fast solution (same-window-p bufname))))))))))) (defun obof-inhibit-frame-creation () "Inhibit creation of extra frames resulting from clicks here." (when one-buffer-one-frame-mode (set (make-local-variable 'one-buffer-one-frame-inhibit) t))) (defun obof-inhibit-pop-up-windows () (when one-buffer-one-frame-mode ;;(set (make-local-variable 'one-buffer-one-frame-inhibit) t) ;; no need? (set (make-local-variable 'obof-same-frame-regexps) `("\\`\\*Customiz.*\\*\\'" . ,obof-same-frame-regexps )) (set (make-local-variable 'same-window-regexps) `("\\`\\*Customiz.*\\*\\'" . ,same-window-regexps)) (set (make-local-variable 'obof-same-window-regexps) 'same-window-regexps) ;; (set (make-local-variable 'display-buffer-function) 'display-buffer-in-same-window) ;; strong. not needed. (set (make-local-variable 'pop-up-windows ) nil) ;; this works for dired ;; this doesn't work very well ;; because it isn't called from the target frame! ;; and because it is too sticky ;; (make-variable-frame-local 'pop-up-windows) ;; (set-frame-parameter nil 'pop-up-windows nil) )) ;; (assq ' pop-up-windows (frame-parameters nil)) ;; pop-up-windows one-buffer-one-frame-inhibit ;; one-buffer-one-frame ;; Todo: ;; make this a patch ;; (define-key dired-mode-map [mouse-2] 'dired-mouse-find-file) (defun dired-mouse-find-file (event) "In Dired, visit the file or directory name you click on." (interactive "e") (let (window pos file) (save-excursion (setq window (posn-window (event-end event)) pos (posn-point (event-end event))) (if (not (windowp window)) (error "No file chosen")) (set-buffer (window-buffer window)) (goto-char pos) (setq file (dired-get-file-for-visit))) (if (file-directory-p file) (or (and (cdr dired-subdir-alist) (dired-goto-subdir file)) (progn (select-window window) (dired file))) (select-window window) (find-file (file-name-sans-versions file t))))) ;; this will cause newly opened files to show up in the dired buffer ;(defvar dired-mode-hook nil) ; to do: this should really only apply to files opened ; from within the dired buffer. (add-hook 'dired-mode-hook 'obof-inhibit-frame-creation) (add-hook 'dired-mode-hook 'obof-inhibit-pop-up-windows) ; customization buffers ;; (setq custom-mode-hook nil) ;; don't do this - would apply to newly opened buffers, too ;; (add-hook 'custom-mode-hook 'obof-inhibit-frame-creation) ;; (add-hook 'custom-mode-hook 'obof-inhibit-pop-up-windows) (aquamacs-set-defaults '((custom-buffer-done-kill t))) (defun open-in-other-frame-p (buf &optional switching) (not (obof-same-frame-p buf switching))) (defcustom delete-window-preserve-buffer '("\*Messages\*" "\*scratch\*" "\*Help\*") "Preserve these buffers when deleting window displaying them. When `one-buffer-one-frame-mode' or `tabbar-mode' are on, a buffer is killed when the last window displaying it is deleted by way of user interaction via high-level commands such as `close-window', unless the buffer name is listed in this customization variable, or this variable is set to `t'." :group 'Aquamacs :group 'frames :type '(choice (repeat string) (set (const "\*Messages\*") (const "\*scratch\*") (const "\*Help\*")) (const t))) (defun killable-buffer-p (buf) "Returns non-nil if buffer BUF may be be killed. Customize `delete-window-preserve-buffer' to configure." (if (or (eq t delete-window-preserve-buffer) (member (get-bufname buf) delete-window-preserve-buffer)) nil t)) ; init (setq aquamacs-newly-opened-windows '() ) ;; this won't work very well - the buffer names stored ;; here could change in the mean time. ;; storing objects won't work either, because ;; comparing them doesn't work once the buffer is killed ;; only for certain special buffers (defun switch-to-buffer-here (buffer &optional norecord) "Switch to another buffer to be shown in the same window. Like `switch-to-buffer', except that even in `one-buffer-one-frame-mode' the current window is switched to the new buffer." (interactive "BSwitch to buffer here: ") (let ((one-buffer-one-frame nil)) (switch-to-buffer buffer norecord))) (defun list-buffers-here (&optional files-only) "Display a list of names of existing buffers. Like `list-buffers', except that even in `one-buffer-one-frame-mode' the current window is switched to the new buffer." (interactive "P") (let ((one-buffer-one-frame nil)) (list-buffers files-only))) (defun next-buffer-here () "Switch to the next buffer in cyclic order in the same window. Like `next-buffer', except that even in `one-buffer-one-frame-mode' the current window is switched to the new buffer." (interactive) (let ((one-buffer-one-frame nil)) (next-buffer))) (defun previous-buffer-here () "Switch to the previous buffer in cyclic order in the same window. Like `previous-buffer', except that even in `one-buffer-one-frame-mode' the current window is switched to the new buffer." (interactive) (let ((one-buffer-one-frame nil)) (previous-buffer))) (define-key one-buffer-one-frame-mode-map [(control x) (shift b)] 'switch-to-buffer-here) (define-key one-buffer-one-frame-mode-map [?\C-x B] 'switch-to-buffer-here) (define-key one-buffer-one-frame-mode-map [(control x) (control shift b)] 'list-buffers-here) (define-key one-buffer-one-frame-mode-map [(control x) (shift right)] 'next-buffer-here) (define-key one-buffer-one-frame-mode-map [(control x) (shift left)] 'previous-buffer-here) (define-key one-buffer-one-frame-mode-map [(control x) (control shift right)] 'next-buffer-here) (define-key one-buffer-one-frame-mode-map [(control x) (control shift left)] 'previous-buffer-here) (defvar obof-force-current-space nil "Instruct `switch-to-buffer' to only visit frames in the current space") (if (running-on-a-mac-p) (defadvice switch-to-buffer (around sw-force-other-frame (&rest args) activate compile) (if one-buffer-one-frame ;; this does mostly the same things as switch-to-buffer. ;; However, we want to be sure not to ;; honor stuff like `obof-same-window-regexps' when obof is off. (let ((norecord (nth 1 args)) (switch t) (window-to-select)) ;; search for a window already displaying this buffer. (walk-windows (lambda (w) (when (and ;; buffer is displayed in this window (equal (window-buffer w) (get-bufobj (car args))) ;; Either window's frame *need not be* in the current space, (or (not obof-force-current-space) ;; or it *is* in the current space (memq (window-frame w) (visible-frame-list)))) (setq switch nil) (setq window-to-select w))) t t) ;) ;; t = include-hidden-frame (must be t) (if switch ;; Did *not* find a suitable window displaying the buffer. (let ((same-window-regexps (if (eq obof-same-window-regexps 'same-window-regexps) same-window-regexps obof-same-window-regexps)) (same-window-buffer-names (if (eq obof-same-window-buffer-names 'same-window-buffer-names) same-window-buffer-names obof-same-window-buffer-names))) (if (or (not (visible-frame-list)) ;; no visible frames (not (frame-visible-p (selected-frame))) ;; selected frame is invisible (open-in-other-frame-p (car args) t)) ;; this buf should open other frame ;; Use a new frame (let ((display-buffer--other-frame-action '(display-buffer-pop-up-frame . nil))) (setq ad-return-value (funcall #'switch-to-buffer-other-frame (car args) (cadr args))) ;; store the frame/buffer information (add-to-list 'aquamacs-newly-opened-windows (cons (selected-window) (buffer-name)))) ;; else : if window is dedictated, use a different window (if (window-dedicated-p (selected-window)) (setq ad-return-value (funcall #'switch-to-buffer-other-window (car args) (cadr args))) ;; else: show in current frame & window ad-do-it))) ;; else (don't switch, just activate another window) ;; we need to do it here, because raise-frame / select frame are ;; ineffective from within walk-windows (when window-to-select (select-frame-set-input-focus (window-frame window-to-select)) ;; raise-frame doesn't select it (select-window window-to-select norecord) ;; normally, the following would only happen in ;; the next top-level event loop (assumption) ;; but because the normal switch-to-buffer does it right away ;; we should do it manually. (set-buffer (window-buffer window-to-select))) (unless ad-return-value (setq ad-return-value (current-buffer))))) ;; else: not one-buffer-one-frame (if (or (visible-frame-list) (string= (substring (get-bufname (car args)) 0 1) " ")) ;; If frames are visible in current space, or buffer (like *empty*) ;; should not be displayed, call vanilla switch-buffer (setq ad-return-value ad-do-it) ;; else pop up a new frame, and avoid switching to a different space (let ((display-buffer--other-frame-action '(display-buffer-pop-up-frame .nil))) (setq ad-return-value (funcall #'switch-to-buffer-other-frame (car args) (cadr args))) ;; store the frame/buffer information (add-to-list 'aquamacs-newly-opened-windows (cons (selected-window) (buffer-name))))) (unless (frame-visible-p (selected-frame)) ;; make sure we don't make *empty* visible (if (not (string= (substring (get-bufname (car args)) 0 1) " ")) (make-frame-visible (selected-frame))))))) ;; (select-window wts) ;; some exception for the speedbar ;; this doesn't work, unfortunately ;; (add-hook 'speedbar-load-hook ;; (lambda () ;; (make-local-variable 'one-buffer-one-frame) ;; (setq one-buffer-one-frame nil) ;; ) ;; ) ;; less elegant, but it works: (add-hook 'speedbar-load-hook (lambda () (defadvice speedbar-find-file (around same-frame (&rest args) protect activate) (if one-buffer-one-frame (progn (setq one-buffer-one-frame nil) (unwind-protect ad-do-it (setq one-buffer-one-frame t) )) ad-do-it)))) ;; make sure that when a minibuffer is ready to take input, ;; the appropriate frame is raised (made visible) ;; using minibuffer-auto-raise globally has unpleasant results, ;; with frames losing focus all the time. speedbar doesn't work either. (if (running-on-a-mac-p) (add-hook 'minibuffer-setup-hook (defun maybe-raise-frame () (unless one-buffer-one-frame (raise-frame))))) ;; we'd like to open new frames for some stuff ; one could make h-W just kill the buffer and then handle things here ; however, kill-buffer is called a lot for buffers that are not associated ; with a frame and we would need to make sure that only buffers for ; which a new frame was created will take their dedicated frame with ; them when they are killed! ; maybe the previous force-other-frame should keep track of ; newly opened frames! ;; ; quit-window is usually called by some modes when the user enters 'q' ;; ; e.g. in dired. we want to delete the window then. ;; advising quit-window like this will cause some things to fail, e.g. ;; SLIME will switch buffers back in the wrong window after 'q' deletes ;; the window ;; (defadvice quit-window (around always-dedicated (&optional kill window) ;; activate protect) ;; (interactive "P") ;; (if (and one-buffer-one-frame ;; (or (not tabbar-mode) ;; (< (length (tabbar-tabs (tabbar-current-tabset))) 2))) ;; (let* ((one-buffer-one-frame nil) ;; (win (or window (selected-window))) ;; (save (window-dedicated-p win))) ;; (set-window-dedicated-p win t) ;; (ad-set-arg 1 win) ;; ad-do-it ;; (if (window-live-p win) ;; (set-window-dedicated-p win save)) ;; ) ;; ;; else ;; ad-do-it ;; )) (when (running-on-a-mac-p) ; quit-window is usually called by some modes when the user enters 'q' ; e.g. in dired. we want to delete the window then. ; (ad-disable-advice 'bury-buffer 'around 'always-dedicated) (defadvice bury-buffer (around maybe-delete-window (&optional buffer) activate protect) (let ((the-buffer (current-buffer))) ad-do-it ;; from the documentation of bury-buffer: ;; Also, if buffer is nil or omitted, remove the current buffer from the ;; selected window if it is displayed there. (if (and one-buffer-one-frame (null buffer)) ;; only if nil ;; delete the frame if necessary ;; only delete a whole frame with only the window in it ;; because extra windows are usually created with pop-to-buffer etc. ;; so a package expects them to exist to do something with them. ;; if a frame was created, however, this heuristic doesn't work out ;; seems to work with SLIME like this... (delete-window-if-created-for-buffer the-buffer 'only-frame))))) (defun aquamacs-display-buffer (buffer &optional not-this-window frame) (if one-buffer-one-frame-mode (let ((same-window-regexps (if (eq obof-same-window-regexps 'same-window-regexps) same-window-regexps obof-same-window-regexps)) (same-window-buffer-names (if (eq obof-same-window-buffer-names 'same-window-buffer-names) same-window-buffer-names obof-same-window-buffer-names)) (display-buffer-function nil)) (if (and one-buffer-one-frame (open-in-other-frame-p buffer)) (let ((pop-up-frames t) ;; open in a new frame! (sframe (selected-frame)) (swin (selected-window))) ;; (message "Pop-up-frames is %s" pop-up-frames) (let ((ret (display-buffer buffer not-this-window frame))) ;; make sure the old frame stays the selected one ;; this is to maintain compatibility with opening ;; a new window inside the frame, where the input focus ;; stays in the original window. ;; dr 12/2006 - we'll try this again, because ;; that's the way display-buffer is supposed to work. (unless (or (eq display-buffer-reuse-frames 'select) ;; re-selecting the old frame would cause a space switch, ;; assuming the new one is on the active space. (not (ns-frame-is-on-active-space-p sframe))) ;; we can't use select-frame-set-input-focus because ;; that would raise the (main) frame over the newly ;; opened one, and we don't want that. (select-frame sframe) (cond ((memq window-system '(x mac ns)) (x-focus-frame sframe)) ((eq window-system 'w32) (w32-focus-frame sframe))) (select-window swin)) ret)) (display-buffer buffer not-this-window frame))) ;; (if (and nil tabbar-mode (not not-this-window)) ;; display-buffer: "Make buffer appear in some window but don't select it." ;; so perhaps this is incompatible, because we need to guarantee that the buffer is visible, but not selected ;; that's not really possible with tabs. ;; (switch-to-buffer-in-tab buffer) ;; to do: evaluate the "frame" argument properly and only do this if there's an existing tab. ;; otherwise, we'll never pop up a separate window. (let ((display-buffer-function nil)) (display-buffer buffer not-this-window frame)))) (defun display-buffer-in-same-window (&rest args) (let (pop-up-windows pop-up-frames (same-window-regexps '(".*Custom.*")) (display-buffer-function nil)) (apply #'display-buffer args))) ;; (setq display-buffer-reuse-frames 'select) (if (running-on-a-mac-p) (aquamacs-set-defaults '((display-buffer-reuse-frames t) (display-buffer-function aquamacs-display-buffer)))) (defun aquamacs-delete-window (&optional window) "Remove WINDOW from the display. Default is `selected-window'. If WINDOW is the only one in its frame, then `delete-frame' too, even if it's the only visible frame." (interactive) (setq window (or window (selected-window))) (select-window window) (if (one-window-p t) (aquamacs-delete-frame) (delete-window (selected-window)))) (defun delete-window-if-one-buffer-one-frame () ;; only delete window when tabbar-mode is not on! (with-current-buffer (current-buffer) (if (and one-buffer-one-frame (not (and (boundp 'tabbar-mode) tabbar-mode)) (not (memq '(lambda () (condition-case nil (delete-window) (error nil))) kill-buffer-hook))) (delete-window-if-created-for-buffer)))) (defvar aquamacs-last-frame-empty-buffer nil) (defun init-aquamacs-last-frame-empty-buffer () (when aquamacs-keep-running-via-empty-frame (unless (buffer-live-p aquamacs-last-frame-empty-buffer) (setq aquamacs-last-frame-empty-buffer (generate-new-buffer " *empty*")) (with-current-buffer aquamacs-last-frame-empty-buffer (setq buffer-read-only t) (setq header-line-format nil))) aquamacs-last-frame-empty-buffer)) (defcustom aquamacs-keep-running-via-empty-frame t "Keep Aquamacs application running even when the last frame is closed. Aquamacs uses invisible, empty frames to keep the application running when the user closes the last empty frame. This customization variable may be set to `nil' if such empty frames become visible inadvertently." :type 'boolean) (defvar aquamacs-last-frame-empty-frame nil) (defun aquamacs-make-empty-frame (parms) (when aquamacs-keep-running-via-empty-frame ;; return nil otherwise (let ((frame-to-delete (when (and aquamacs-last-frame-empty-frame (frame-live-p aquamacs-last-frame-empty-frame) (not (ns-frame-is-on-active-space-p aquamacs-last-frame-empty-frame))) (prog1 aquamacs-last-frame-empty-frame (setq aquamacs-last-frame-empty-frame nil))))) (let ((all-parms (append '((name . " Aquamacs") ;; initial space hides frame from lists (fullscreen . nil) (visibility . nil)) parms))) (if (and aquamacs-last-frame-empty-frame (frame-live-p aquamacs-last-frame-empty-frame) (not (frcmds-frame-iconified-p aquamacs-last-frame-empty-frame))) (modify-frame-parameters aquamacs-last-frame-empty-frame (cons '(fullscreen . nil) parms)) (setq aquamacs-last-frame-empty-frame (make-frame all-parms)))) (select-frame aquamacs-last-frame-empty-frame) (raise-frame aquamacs-last-frame-empty-frame) (if frame-to-delete (delete-frame frame-to-delete))) aquamacs-last-frame-empty-frame)) (defvar aquamacs-deleted-frame-position nil) (defun aquamacs-delete-frame (&optional frame) ;; this function takes are to create a hidden frame that can receive ;; keyboard input while all other frames are iconified or deleted ;; The hidden frame shows a special, read-only *empty* buffer. ;; are we deleting a non-special frame? (let ((f (or frame (selected-frame)))) ;; HACK: the buffer has been killed already at this point ;; so we must consider the frame title instead, which has not been updated yet (unless (or (special-display-p (frame-parameter f 'name)) (if (> (length (frame-parameter f 'name)) 0) (string= (substring (frame-parameter f 'name) 0 1) " "))) ;; store frame position for reuse (setq aquamacs-deleted-frame-position `((top . ,(frame-parameter f 'top)) (left . ,(frame-parameter f 'left)) (width . ,(frame-parameter f 'width)) (height . ,(frame-parameter f 'height))))) (with-current-buffer (current-buffer) ; delete-frame changes current buffer ;; current buffer must be preserved (e.g., for other kill-buffer-hook functions) (condition-case nil ;; do not delete the last visible frame if there are others hidden: ;; doing so prevents Aquamacs from receiving keyboard input (NS problem?) (progn (if (and aquamacs-keep-running-via-empty-frame (equal (visible-frame-list) (list (or frame (selected-frame))))) (error "obof1 error") ;; create *empty* frame or hide current one (delete-frame (or frame (selected-frame)))) (unless (visible-frame-list) ;; delete-frame may succeed if iconified frames are around (error "obof2 error"))) (error ;; we're doing delete-frame later ;;(run-hook-with-args 'delete-frame-functions f) (let ((confirm-nonexistent-file-or-buffer) (one-buffer-one-frame-mode nil) (pop-up-frames nil) (smart-frame-positioning-mode nil)) (delete-other-windows) (set-window-dedicated-p (selected-window) nil) ;; select read-only special buffer in case it gets any input (let ((hb (init-aquamacs-last-frame-empty-buffer))) (if (null hb) (delete-frame (or frame (selected-frame))) ;; actually delete frame or show error message ;; else, go via empty buffer (with-current-buffer hb ;; to do: we should re-use a hidden frame if it exists. (let ((hf (aquamacs-make-empty-frame aquamacs-deleted-frame-position))) (when hf (if (and (not (eq f hf)) (frame-live-p f)) (delete-frame f t)) (select-window (frame-first-window hf)) (switch-to-buffer hb 'norecord) (make-frame-visible hf) ; HACK: must do this first, presumably to convince NS to make it key. (make-frame-invisible hf t)))))))))))) (defun aquamacs-handle-frame-iconified (&optional frame) "Handle frame iconification. If FRAME given, the frame has not been iconified. If FRAME is nil, the iconified frame is invisible and not necessarily selected." (interactive) (when (or (null (visible-frame-list)) (and frame (equal (visible-frame-list) (list frame)))) ;; if no other frame visible, create hidden backup frame to receive keyboard input (let ((bup-frame (aquamacs-make-empty-frame (mapcar (lambda (x) (cons x (frame-parameter frame x))) '(top left width height)) ))) (when bup-frame (let ((confirm-nonexistent-file-or-buffer) (one-buffer-one-frame nil) (pop-up-frames nil) (tabbar-mode nil)) (switch-to-buffer (init-aquamacs-last-frame-empty-buffer)) (make-frame-visible (selected-frame)) ; HACK: must do this first, presumably to convince NS to make it key. (make-frame-invisible (selected-frame))))))) ;; usually, iconify-frame is bound to 'ignore (define-key special-event-map [iconify-frame] 'aquamacs-handle-frame-iconified) ;; other Lisp code doesn't cause iconify-frame to be sent: (defadvice iconify-frame (after leave-hidden-frame (&rest args) activate compile) (aquamacs-handle-frame-iconified (car args))) ;; delete window when buffer is killed ;; but only do so if aquamacs opened a new frame&window for ;; this buffer (e.g. during switch-to-buffer) (defun delete-window-if-created-for-buffer (&optional buffer whole-frame-only) (with-current-buffer (current-buffer) (let ((buf (or buffer (current-buffer)))) (let ((winlist (find-all-windows-internal buf))) (mapc (lambda (win) ;;force deletion if buffer is not killable (if (or (not whole-frame-only) (equal 1 (length (window-list (window-frame win) 'no-minibuf)))) (delete-window-if-created-for-this-buffer win (buffer-name buf) t))) ; (not (killable-buffer-p buf))) winlist)) ;; some functions like find-alternate-file (via kill-buffer-hook) ;; rely on the buffer still being current. we're not killing it after all! ))) (defun delete-window-if-created-for-this-buffer (win buf-name skip-check) "Delete the window (sometimes) Deletes a window WIN if appropriate. SKIP-CHECK non-nil causes the window WIN to be deleted even if there is no record of opening the window just for this purpose." ;; used by osxkeys, too ;; as of now, we're always forcing the deletion of a window if the user requests it. ;; (if (window-live-p win) (let ((elt (car (member (cons win buf-name) aquamacs-newly-opened-windows)))) (if (and (or (not buf-name) (not (same-window-p buf-name)) ;; always open in same window, so don't close the window (window-dedicated-p win)) ;; dedicated windows should be closed (or skip-check elt)) ;; only affect frames opened for this purpose (progn ;; remove entry from windows list (if elt (setq aquamacs-newly-opened-windows (delq elt aquamacs-newly-opened-windows))) ;; delete the window (or make the frame invisible) (condition-case nil (if (window-live-p win) (delete-window win)) ;; only get rid of that current window (error (let ((f (window-frame win))) ;;(selected-frame))) ;; hook can contain smart-frame-pos call (run-hook-with-args 'delete-frame-functions f) (make-frame-invisible f t) (if (find-all-frames-internal (get-buffer "*Messages*")) (select-frame (car (find-all-frames-internal (get-buffer "*Messages*"))))))))) ;; else: ;; decide not to delete / make invisible ;; then switch buffer ;; to whatever was shown previously (does this work well???) (with-selected-window win (previous-buffer-here)))))) (if (running-on-a-mac-p) (add-hook 'kill-buffer-hook 'delete-window-if-one-buffer-one-frame t)) ;; this is what's bound to Apple-W ;; and what can called programmatically (instead of bury-buffer, etc.) (defun close-window () "Deletes the tab, window or frame and maybe kills buffer. Deletes the selected tab, window or frame showing the current buffer. In `tabbar-mode' or in `one-buffer-one-frame-mode', and if the tab, window or frame is the only one showing the buffer, kill the buffer, too. Ask user whether to kill it if appropriate." (interactive) ;; quit current command if in minibuffer (when (minibuffer-window-active-p (minibuffer-window (selected-frame))) (abort-recursive-edit)) ;; else, close tab or window+frame (cond ((and (boundp tabbar-mode) tabbar-mode) (let ((tabbar-retain-windows-when-tab-deleted nil)) (tabbar-close-tab))) (one-buffer-one-frame-mode (close-current-window-asktosave)) (t ;; if neither OBOF nor tabs, then we don't kill the buffer (aquamacs-delete-window)))) (defun close-current-window-asktosave (&optional force-delete-frame) "Delete current buffer, close selected window (and its frame if `one-buffer-one-frame'. Beforehand, ask to save file if necessary." (interactive) (let ((wind (selected-window)) (killable (and (killable-buffer-p (window-buffer)) ;; theoretically, we should check if, in case ;; of force-delete-frame all windows display ;; the same buffer, in which case it is ;; killable again. practically, this situation ;; shouldn't occur to often, so we skip that ;; someone tedious check. (eq (length (find-all-windows-internal (window-buffer) 'only_visible_ones)) 1)))) (when (frame-visible-p (window-frame wind)) (select-frame-set-input-focus (selected-frame)) ; ask before killing (with-current-buffer (window-buffer) (when (and ;(eq (current-buffer) (window-buffer)) ; only if a document is shown killable (eq (string-match "\\*.*\\*" (buffer-name)) nil) (eq (string-match " SPEEDBAR" (buffer-name)) nil)) ; has no minibuffer! (if (and (or buffer-file-name buffer-offer-save) (buffer-modified-p)) ;; a lot of buffers (e.g. dired) may be modified, ;; but have no file name (if (aquamacs-ask-for-confirmation (format "Save buffer %s to file before closing window? The buffer contains unsaved changes which will be lost if you discard them now." (buffer-name)) nil (format "Save%s" (if buffer-file-name "" "...")) "Don't Save" t) (progn (if (listp last-nonmenu-event) (mac-key-save-file) (save-buffer)) (if (buffer-modified-p) (keyboard-quit) (message "File saved."))) ;; mark as not modified, so it will be killed for sure (set-buffer-modified-p nil)) (message "")))) ;; only if not a *special* buffer ;; if the buffer is shown in another window , just delete the current win (if one-buffer-one-frame (let* ((this-buf (window-buffer)) (this-buf-name (buffer-name this-buf))) (if (if killable (kill-buffer this-buf) t ) ;; else ;; always delete ;; unless user said "no" (progn (message "") ;; we don't want a message in the echo area of the next window! (delete-window-if-created-for-this-buffer wind this-buf-name t) )) ) ;; else not one-buffer=one-frame (progn (if killable (kill-buffer (window-buffer wind))) (when (window-live-p wind) (if (or force-delete-frame ;; still needed? (window-dedicated-p wind)) (aquamacs-delete-frame (window-frame wind) ) ; delete window/frame, hide if ; necessary ;; else (progn (select-window wind) (aquamacs-delete-window wind) ) ) ) ) ) ) ) ) (when (running-on-a-mac-p) (defun handle-delete-frame (event) "Handle delete-frame events from the X server." (interactive "e") (let ((frame (posn-window (event-start event))) (i 0) (delw nil)) (select-frame frame) (while (and (frame-first-window frame) (window-live-p (frame-first-window frame)) (select-window (frame-first-window frame)) (setq delw (cons (frame-first-window frame) delw) delb (window-buffer)) (or (let ((last-nonmenu-event)) (close-window) ;; (close-current-window-asktosave nil) ) t) (frame-live-p frame) ;; the above closing action will have deleted the window, so ;; we have moved on. ;; ensure that this is the case (i.e. no cancels) (not (and (memq (frame-first-window frame) delw) (eq (window-buffer) delb)))))) ;; needed due to bug in main event loop (first mouse event ;; is interpreted with wrong current buffer) (set-buffer (window-buffer (selected-window)))) (define-key special-event-map [ns-application-reopen] 'ignore) (define-key global-map [ns-new-frame] 'new-empty-buffer-other-frame) ) ;; app-activated is no longer sent due to event loop problems. ;; it is also not necessary. At least in 10.8/Emacs 24, these events are handled correctly. ;; FIXES IN VARIOUS PLACES ;; make sure that C-mouse-1 menu acts locally (if (running-on-a-mac-p) (defadvice mouse-buffer-menu (around select-buffer-same-frame (&rest args) activate protect) (let ((one-buffer-one-frame nil)) ad-do-it))) ;; ediff-directories, e.g. uses split-window to create a new window ;; in a frame, and then `switch-to-buffer', which should simply show ;; another buffer in the newly created window. Problem is, in this ;; mode, this will open a new buffer. (defadvice split-window (before inhibit-one-buffer-one-frame (&rest args) activate compile) (when one-buffer-one-frame-mode (setq one-buffer-one-frame-inhibit t) ;; clear flag as soon as command has finished (or similar) (run-with-idle-timer 0 nil (lambda () (setq one-buffer-one-frame-inhibit nil))))) ;; (defadvice delete-window (before inhibit-one-buffer-one-frame ;; (&rest args) activate compile) ;; (when one-buffer-one-frame-mode ;; (setq one-buffer-one-frame-inhibit t) ;; ;; clear flag as soon as command has finished (or similar) ;; (run-with-idle-timer ;; 0 nil ;; (lambda () (setq one-buffer-one-frame-inhibit nil))))) (defadvice desktop-read (around inhibit-one-buffer-one-frame (&rest args) activate compile) (let ((one-buffer-one-frame-inhibit t)) ad-do-it)) ;; Commands (defun aquamacs-join-windows () "Join windows in selected or all frames. If selected frame contains more than one window, join the windows together. Otherwise, combine all other frames into selected frame." (interactive) (if tabbar-mode (tabbar-window-merge-windows-in-frame) (delete-other-windows))) (defun aquamacs-split-window-vertically () "Split window, select new window. Like `split-window-vertically' without further arguments, but select the newly created window." (interactive) (select-window (split-window-vertically))) (defun raise-next-frame () "Raise the next frame. See also `raise-previous-frame' and `other-frame'. An Aquamacs-only function." (interactive) (other-frame 1)) (defun raise-previous-frame () "Raise the previous frame. See also `raise-next-frame' and `other-frame'. An Aquamacs-only function." (interactive) (other-frame -1)) (defun other-previous-window () "Like `next-window', but in the opposite direction." (interactive) (other-window -1)) (provide 'one-buffer-one-frame) ;; for ae24windowing branch (when (and (running-on-a-mac-p) (ad-is-advised 'switch-to-buffer)) (ad-disable-advice 'switch-to-buffer 'around 'sw-force-other-frame)) (setq display-buffer-function nil) tabbar-2.2/right.tiff000066400000000000000000000156241332640313100146030ustar00rootroot00000000000000II*:xc`` 3$2,by<fQ' &   HT1fn()=RsH vright.tiffCreated with GIMPYY HLinomntrRGB XYZ  1acspMSFTIEC sRGB-HP cprtP3desclwtptbkptrXYZgXYZ,bXYZ@dmndTpdmddvuedLview$lumimeas $tech0 rTRC< gTRC< bTRC< textCopyright (c) 1998 Hewlett-Packard CompanydescsRGB IEC61966-2.1sRGB IEC61966-2.1XYZ QXYZ XYZ o8XYZ bXYZ $descIEC http://www.iec.chIEC http://www.iec.chdesc.IEC 61966-2.1 Default RGB colour space - sRGB.IEC 61966-2.1 Default RGB colour space - sRGBdesc,Reference Viewing Condition in IEC61966-2.1,Reference Viewing Condition in IEC61966-2.1view_. \XYZ L VPWmeassig CRT curv #(-27;@EJOTY^chmrw| %+28>ELRY`gnu| &/8AKT]gqz !-8COZfr~ -;HUcq~ +:IXgw'7HYj{+=Oat 2FZn  % : O d y  ' = T j " 9 Q i  * C \ u & @ Z t .Id %A^z &Ca~1Om&Ed#Cc'Ij4Vx&IlAe@e Ek*Qw;c*R{Gp@j>i  A l !!H!u!!!"'"U"""# #8#f###$$M$|$$% %8%h%%%&'&W&&&''I'z''( (?(q(())8)k))**5*h**++6+i++,,9,n,,- -A-v--..L.../$/Z///050l0011J1112*2c223 3F3334+4e4455M555676r667$7`7788P8899B999:6:t::;-;k;;<' >`>>?!?a??@#@d@@A)AjAAB0BrBBC:C}CDDGDDEEUEEF"FgFFG5G{GHHKHHIIcIIJ7J}JK KSKKL*LrLMMJMMN%NnNOOIOOP'PqPQQPQQR1R|RSS_SSTBTTU(UuUVV\VVWDWWX/X}XYYiYZZVZZ[E[[\5\\]']x]^^l^__a_``W``aOaabIbbcCccd@dde=eef=ffg=ggh?hhiCiijHjjkOkklWlmm`mnnknooxop+ppq:qqrKrss]sttptu(uuv>vvwVwxxnxy*yyzFz{{c{|!||}A}~~b~#G k͂0WGrׇ;iΉ3dʋ0cʍ1fΏ6n֑?zM _ɖ4 uL$h՛BdҞ@iءG&vVǥ8nRĩ7u\ЭD-u`ֲK³8%yhYѹJº;.! zpg_XQKFAǿ=ȼ:ɹ8ʷ6˶5̵5͵6ζ7ϸ9к<Ѿ?DINU\dlvۀ܊ݖޢ)߯6DScs 2F[p(@Xr4Pm8Ww)Kmxc``3lG@%q ~r\d`OKh|S~%; F= :     *  Q<D()=RsH Lright.tiffCreated with GIMPYY HLinomntrRGB XYZ  1acspMSFTIEC sRGB-HP cprtP3desclwtptbkptrXYZgXYZ,bXYZ@dmndTpdmddvuedLview$lumimeas $tech0 rTRC< gTRC< bTRC< textCopyright (c) 1998 Hewlett-Packard CompanydescsRGB IEC61966-2.1sRGB IEC61966-2.1XYZ QXYZ XYZ o8XYZ bXYZ $descIEC http://www.iec.chIEC http://www.iec.chdesc.IEC 61966-2.1 Default RGB colour space - sRGB.IEC 61966-2.1 Default RGB colour space - sRGBdesc,Reference Viewing Condition in IEC61966-2.1,Reference Viewing Condition in IEC61966-2.1view_. \XYZ L VPWmeassig CRT curv #(-27;@EJOTY^chmrw| %+28>ELRY`gnu| &/8AKT]gqz !-8COZfr~ -;HUcq~ +:IXgw'7HYj{+=Oat 2FZn  % : O d y  ' = T j " 9 Q i  * C \ u & @ Z t .Id %A^z &Ca~1Om&Ed#Cc'Ij4Vx&IlAe@e Ek*Qw;c*R{Gp@j>i  A l !!H!u!!!"'"U"""# #8#f###$$M$|$$% %8%h%%%&'&W&&&''I'z''( (?(q(())8)k))**5*h**++6+i++,,9,n,,- -A-v--..L.../$/Z///050l0011J1112*2c223 3F3334+4e4455M555676r667$7`7788P8899B999:6:t::;-;k;;<' >`>>?!?a??@#@d@@A)AjAAB0BrBBC:C}CDDGDDEEUEEF"FgFFG5G{GHHKHHIIcIIJ7J}JK KSKKL*LrLMMJMMN%NnNOOIOOP'PqPQQPQQR1R|RSS_SSTBTTU(UuUVV\VVWDWWX/X}XYYiYZZVZZ[E[[\5\\]']x]^^l^__a_``W``aOaabIbbcCccd@dde=eef=ffg=ggh?hhiCiijHjjkOkklWlmm`mnnknooxop+ppq:qqrKrss]sttptu(uuv>vvwVwxxnxy*yyzFz{{c{|!||}A}~~b~#G k͂0WGrׇ;iΉ3dʋ0cʍ1fΏ6n֑?zM _ɖ4 uL$h՛BdҞ@iءG&vVǥ8nRĩ7u\ЭD-u`ֲK³8%yhYѹJº;.! zpg_XQKFAǿ=ȼ:ɹ8ʷ6˶5̵5͵6ζ7ϸ9к<Ѿ?DINU\dlvۀ܊ݖޢ)߯6DScs 2F[p(@Xr4Pm8Ww)Kmtabbar-2.2/right_disabled.tiff000066400000000000000000000157061332640313100164330ustar00rootroot00000000000000II*:xc`` }~$2,bs<fQ' .  H\1nv()=RsH ~:right_disabled.tiffCreated with GIMPYY HLinomntrRGB XYZ  1acspMSFTIEC sRGB-HP cprtP3desclwtptbkptrXYZgXYZ,bXYZ@dmndTpdmddvuedLview$lumimeas $tech0 rTRC< gTRC< bTRC< textCopyright (c) 1998 Hewlett-Packard CompanydescsRGB IEC61966-2.1sRGB IEC61966-2.1XYZ QXYZ XYZ o8XYZ bXYZ $descIEC http://www.iec.chIEC http://www.iec.chdesc.IEC 61966-2.1 Default RGB colour space - sRGB.IEC 61966-2.1 Default RGB colour space - sRGBdesc,Reference Viewing Condition in IEC61966-2.1,Reference Viewing Condition in IEC61966-2.1view_. \XYZ L VPWmeassig CRT curv #(-27;@EJOTY^chmrw| %+28>ELRY`gnu| &/8AKT]gqz !-8COZfr~ -;HUcq~ +:IXgw'7HYj{+=Oat 2FZn  % : O d y  ' = T j " 9 Q i  * C \ u & @ Z t .Id %A^z &Ca~1Om&Ed#Cc'Ij4Vx&IlAe@e Ek*Qw;c*R{Gp@j>i  A l !!H!u!!!"'"U"""# #8#f###$$M$|$$% %8%h%%%&'&W&&&''I'z''( (?(q(())8)k))**5*h**++6+i++,,9,n,,- -A-v--..L.../$/Z///050l0011J1112*2c223 3F3334+4e4455M555676r667$7`7788P8899B999:6:t::;-;k;;<' >`>>?!?a??@#@d@@A)AjAAB0BrBBC:C}CDDGDDEEUEEF"FgFFG5G{GHHKHHIIcIIJ7J}JK KSKKL*LrLMMJMMN%NnNOOIOOP'PqPQQPQQR1R|RSS_SSTBTTU(UuUVV\VVWDWWX/X}XYYiYZZVZZ[E[[\5\\]']x]^^l^__a_``W``aOaabIbbcCccd@dde=eef=ffg=ggh?hhiCiijHjjkOkklWlmm`mnnknooxop+ppq:qqrKrss]sttptu(uuv>vvwVwxxnxy*yyzFz{{c{|!||}A}~~b~#G k͂0WGrׇ;iΉ3dʋ0cʍ1fΏ6n֑?zM _ɖ4 uL$h՛BdҞ@iءG&vVǥ8nRĩ7u\ЭD-u`ֲK³8%yhYѹJº;.! zpg_XQKFAǿ=ȼ:ɹ8ʷ6˶5̵5͵6ζ7ϸ9к<Ѿ?DINU\dlvۀ܊ݖޢ)߯6DScs 2F[p(@Xr4Pm8Ww)Kmxc`Z`  Mw7gl&[F0s/C. ?R]9pf-0~Ԉ?mEKyװ8    H\  snv()=RsH ~right_disabled.tiffCreated with GIMPYY HLinomntrRGB XYZ  1acspMSFTIEC sRGB-HP cprtP3desclwtptbkptrXYZgXYZ,bXYZ@dmndTpdmddvuedLview$lumimeas $tech0 rTRC< gTRC< bTRC< textCopyright (c) 1998 Hewlett-Packard CompanydescsRGB IEC61966-2.1sRGB IEC61966-2.1XYZ QXYZ XYZ o8XYZ bXYZ $descIEC http://www.iec.chIEC http://www.iec.chdesc.IEC 61966-2.1 Default RGB colour space - sRGB.IEC 61966-2.1 Default RGB colour space - sRGBdesc,Reference Viewing Condition in IEC61966-2.1,Reference Viewing Condition in IEC61966-2.1view_. \XYZ L VPWmeassig CRT curv #(-27;@EJOTY^chmrw| %+28>ELRY`gnu| &/8AKT]gqz !-8COZfr~ -;HUcq~ +:IXgw'7HYj{+=Oat 2FZn  % : O d y  ' = T j " 9 Q i  * C \ u & @ Z t .Id %A^z &Ca~1Om&Ed#Cc'Ij4Vx&IlAe@e Ek*Qw;c*R{Gp@j>i  A l !!H!u!!!"'"U"""# #8#f###$$M$|$$% %8%h%%%&'&W&&&''I'z''( (?(q(())8)k))**5*h**++6+i++,,9,n,,- -A-v--..L.../$/Z///050l0011J1112*2c223 3F3334+4e4455M555676r667$7`7788P8899B999:6:t::;-;k;;<' >`>>?!?a??@#@d@@A)AjAAB0BrBBC:C}CDDGDDEEUEEF"FgFFG5G{GHHKHHIIcIIJ7J}JK KSKKL*LrLMMJMMN%NnNOOIOOP'PqPQQPQQR1R|RSS_SSTBTTU(UuUVV\VVWDWWX/X}XYYiYZZVZZ[E[[\5\\]']x]^^l^__a_``W``aOaabIbbcCccd@dde=eef=ffg=ggh?hhiCiijHjjkOkklWlmm`mnnknooxop+ppq:qqrKrss]sttptu(uuv>vvwVwxxnxy*yyzFz{{c{|!||}A}~~b~#G k͂0WGrׇ;iΉ3dʋ0cʍ1fΏ6n֑?zM _ɖ4 uL$h՛BdҞ@iءG&vVǥ8nRĩ7u\ЭD-u`ֲK³8%yhYѹJº;.! zpg_XQKFAǿ=ȼ:ɹ8ʷ6˶5̵5͵6ζ7ϸ9к<Ѿ?DINU\dlvۀ܊ݖޢ)߯6DScs 2F[p(@Xr4Pm8Ww)Kmtabbar-2.2/tabbar-window.el000066400000000000000000001101711332640313100156670ustar00rootroot00000000000000;; Tabbar-window.el --- "Window Tabs" for tabbar-mode: Tab-set is ;; specific to each window, and tabbar is hidden when only a ;; single tab exists for that window. Requires that tabbar.el and ;; aquamacs-tabbar.el be loaded first. ;; This file is part of Aquamacs Emacs. ;; This program is free software; you can redistribute it and/or ;; modify it under the terms of the GNU General Public License as ;; published by the Free Software Foundation; either version 3, or (at ;; your option) any later version. ;; This program is distributed in the hope that it will be useful, but ;; WITHOUT ANY WARRANTY; without even the implied warranty of ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ;; General Public License for more details. ;; You should have received a copy of the GNU General Public License ;; along with this program; see the file COPYING. If not, write to ;; the Free Software Foundation, Inc., 51 Franklin Street, Fifth ;; Floor, Boston, MA 02110-1301, USA. ;; Author: Nathaniel Cunningham ;; Maintainer: Nathaniel Cunningham ;; Created: February 2008 ;; (C) Copyright 2008, 2012 the Aquamacs Project (require 'tabbar) (require 'aquamacs-tools) (defvar tabbar-window-alist nil) (defvar tabbar-window-cache nil) ;; (defcustom tabbar-window-new-buffers nil ;; "*Specify the behavior when a new buffer is opened in tabbar-mode. ;; The following options are available: ;; - `tab' ;; Buffer is created in current window and assigned a new tab. ;; - `no-tab' ;; Buffer is created in current window, with no tab or tab bar; window's ;; previous tabset is deleted, although buffers are not closed or killed. ;; - default ;; Buffer is created in a new frame. (Lone buffers show no tabs.)" ;; :group 'tabbar ;; :type '(choice :tag "New buffer gets created in..." ;; (const :tag "Current Window with New Tab" nil) ;; (const :tag "Current Window without a Tab" no-tab) ;; (const :tag "New Frame" nil))) ;; for "buffer tabs", it makes sense to have tabbar-current-tabset always ;; buffer-local. This is not sensible for "window tabs". Window-local variables ;; do not exist in emacs; therefore we use frame-local. ;; Probably doesn't matter much, now that we always update tabbar-current-tabset ;; when (tabbar-current-tabset) is called. (makunbound 'tabbar-current-tabset) (defvar tabbar-current-tabset nil "The tab set currently displayed on the tab bar.") ;(make-variable-frame-local 'tabbar-current-tabset) ;; redefine tabbar-current-tabset to ALWAYS update the value ;; of tabbar-current-tabset. Required since the same buffer can have tabs ;; in multiple tabsets. Reasonable to do, as this does not redefine all tabsets ;; when "window tabs" are on -- see tabbar-window-current-tabset below. (defun tabbar-current-tabset (&optional update) "Return the tab set currently displayed on the tab bar. If optional argument UPDATE is non-nil, call the user defined function `tabbar-current-tabset-function' to obtain it. Otherwise return the current cached copy." (setq tabbar-current-tabset (if tabbar-current-tabset-function (funcall tabbar-current-tabset-function)))) (defun tabbar-window-buffer-list () "Return the list of buffers to show in tabs. Exclude internal buffers." (apply #'nconc (mapcar (lambda (b) (cond ((string= (substring (buffer-name b) 0 1) " ") ; and (null buffer-file-name) nil) ((buffer-live-p b) (list b)))) (buffer-list)))) (defun window-number (window) "Return window ID as a number." (string-to-number (nth 1 (save-match-data (split-string (format "%s" window) "\\( (length (window-list (window-frame window) 'no-minibuf)) 1)) ;; this can cause a bit of flicker, but that's still better (run-with-idle-timer 0 nil 'add-to-list 'header-line-inhibit-window-list window t) (add-to-list 'header-line-inhibit-window-list window t)) ;; otherwise, ensure this window has a tabbar (setq header-line-inhibit-window-list (delq window header-line-inhibit-window-list)))) ;; window doesn't exist: remove it from alist ... (setq tabbar-window-alist (delq elt tabbar-window-alist)) ;; ... and make sure it's removed from header-line-inhibit list (setq header-line-inhibit-window-list (delq window header-line-inhibit-window-list)))))) tabbar-window-alist) (defun tabbar-tabset-names () "Return list of strings giving names of all tabsets" (tabbar-map-tabsets 'symbol-name)) (defun tabbar-window-update-tabsets () "Update tab sets from tabbar-window-alist. Return the current tabset, which corresponds to (selected-window)." ;; run tabbar-window-alist-update for all windows ;; could probably change this to only windows in current frame, ;; since modified frame is active for 'window-configuration-change-hook (tabbar-walk-windows 'tabbar-window-alist-update) ;; (walk-windows 'tabbar-window-alist-update 'nomini t) ;; run tabbar-window-alist-cleanup to remove defunct entries (tabbar-window-alist-cleanup) ;; if the alist has changed, update the tab sets (compare against cache) (unless (equal tabbar-window-alist tabbar-window-cache) ;; cycle through alist. (dolist (elt tabbar-window-alist) ;; for each window group: (let* ((groupnum (car elt)) (groupname (number-to-string groupnum)) (buflist (cdr elt)) (tabset (tabbar-get-tabset groupname))) ;; if the corresponding tabset already exists (if tabset ;; add tabs for any buffers that arent't listed in this group in cache (let ((old-buflist (cdr (assoc groupnum tabbar-window-cache)))) (dolist (buf buflist) (unless (memq buf old-buflist) (tabbar-add-tab tabset (car buf) t) ;;Update the tabset template when we modify the tabset ;;actually don't need to here; tabbar-add-tab does that for us ;;(tabbar-set-template tabset nil) (tabbar-set-template tabset nil)))) ;; if tabset doesn't exist, create new containing first buffer (tabbar-make-tabset groupname (car (car buflist))) ;; get the new tabset (setq tabset (tabbar-get-tabset groupname)) ;; then add any remaining buffers (dolist (buf (cdr buflist)) ;; don't have to update the template, since tabset has no such prop. yet (tabbar-add-tab tabset (car buf) t))))) ;; cycle through tabsets (dolist (tabset-name (tabbar-tabset-names)) (let* ((tabset (tabbar-get-tabset tabset-name)) (tabset-number (string-to-number tabset-name)) (tabset-alist-elt (assq tabset-number tabbar-window-alist))) (if tabset-alist-elt ;; if there is a corresponding window in tabbar-window-alist, ;; cycle through tabs (let ((buflist (cdr tabset-alist-elt))) (dolist (tab (tabbar-tabs tabset)) ;; delete any tabs for buffers not listed with this window (unless (assq (tabbar-tab-value tab) buflist) (tabbar-delete-tab tab)))) ;;if no corresponding window in tabbar-window-alist, ;;delete all containted tabs and tabset (dolist (tab (tabbar-tabs tabset)) (tabbar-delete-tab tab)) ;; if we are deleting the tabset, we don't have to worry about its template (tabbar-delete-tabset tabset)))) ;; duplicate tabbar-window-alist, so we can detect changes (have ;; to ensure that changes within tabbar-window-alist don't affect ;; tabbar-window cache) (setq tabbar-window-cache (copy-tree tabbar-window-alist))) ;; when triggered idle timers, Emacs does not recognize the change in the header line (force-window-update (window-buffer)) ;; return current tabset (tabbar-get-tabset (number-to-string (window-number (selected-window))))) (defvar tabbar-window-immediate-screen-fresh nil "See macro `fast-screen-refresh' in aquamacs-tabbar.") (defun tabbar-window-update-tabsets-when-idle () "Wait for emacs to be idle before updating tabsets. This prevents tabs from updating when a new window shows the current buffer, just before the window shows new buffer." ;; Do not redisplay when changes are made in temporary buffers ;; This assumes that an appropriate buffer is current when run. ;; This function is in first-change-hook, but also in ;; window-configuration-change-hook. (unless (equal " " (substring (buffer-name) 0 1)) (if tabbar-window-immediate-screen-fresh ;; see macro `fast-screen-refresh' in aquamacs-tabbar (tabbar-window-update-tabsets) (run-with-idle-timer 0 nil 'tabbar-window-update-tabsets)))) (defadvice dnd-open-local-file (after dnd-update-tabs activate) (if tabbar-mode (tabbar-window-update-tabsets))) (defun tabbar-update-if-changes-undone () ;; have to wait until idle, or buffer's modified status isn't updated yet (run-with-idle-timer 0 nil (lambda () ;; update tabsets if the last undo made this unmodified (unless (buffer-modified-p (current-buffer)) (tabbar-window-update-tabsets))))) (defun tabbar-window-button-label (name) ;; Use empty string for HOME button, so it doesn't show up. "Return a label for button NAME. That is a pair (ENABLED . DISABLED), where ENABLED and DISABLED are respectively the appearance of the button when enabled and disabled. They are propertized strings which could display images, as specified by the variable `tabbar-button-label'." (if (eq name 'home) (cons "" "") (tabbar-button-label name))) ;; redefine tab labels, adding leading and trailing spaces for clarity (defun tabbar-window-tab-label (tab) "Return a label for TAB. That is, a string used to represent it on the tab bar." (let ((label (format " %s " (tabbar-tab-value tab))) (width (max 1 (/ (window-width) (length (tabbar-view (tabbar-current-tabset))))))) ;; Unless the tab bar auto scrolls to keep the selected tab ;; visible, shorten the tab label to keep as many tabs as possible ;; in the visible area of the tab bar. (if tabbar-auto-scroll-flag (tabbar-expand label width tab) (tabbar-shorten label width)))) (defun tabbar-window-help-on-tab (tab) "Return the help string shown when mouse is onto TAB." (format "%s" (buffer-name (tabbar-tab-value tab)))) (defvar tab-points nil) (defun tabbar-window-select-tab (event tab &optional prefix) "On mouse EVENT, select TAB." (let ((mouse-button (event-basic-type event)) (one-buffer-one-frame nil) (buffer (tabbar-tab-value tab))) (if buffer (cond ((eq mouse-button 'mouse-3) (popup-menu tabbar-context-menu-map event prefix)) (t (set-window-dedicated-p (selected-window) nil) (let ((prevtab (tabbar-get-tab (window-buffer (selected-window)) (tabbar-tab-tabset tab))) (marker (cond ((bobp) (point-min-marker)) ((eobp) (point-max-marker)) (t (point-marker))))) (set-marker-insertion-type marker t) (assq-set prevtab marker 'tab-points)) (switch-to-buffer buffer) (let ((new-pt (cdr (assq tab tab-points)))) (and new-pt (eq (marker-buffer new-pt) (window-buffer (selected-window))) (let ((pos (marker-position new-pt))) (unless (eq pos (point)) (if transient-mark-mode (deactivate-mark)) (goto-char pos)) (set-marker new-pt nil) ;; delete marker ))))) ;; if there's no tab associated with clicked spot, use ;; special keymap for empty tab bar (cond ((eq mouse-button 'mouse-3) ;; context menu on right-click (popup-menu tabbar-empty-context-menu-map event prefix)) ((eq (event-click-count event) 2) ;; new tab on double-click (tabbar-new-tab)))))) (defun tabbar-windows-per-buffer (buffer) "Return a list of numbers corresponding to window tabsets to which the specified BUFFER belongs." (let (buffer-window-list) (dolist (elt tabbar-window-alist) (let ((wnumber (car elt)) (wbuffers (cdr elt))) (when (assq buffer wbuffers) (add-to-list 'buffer-window-list wnumber)))) buffer-window-list)) (defun tabbar-window-other-instances (tab) "Return t if the buffer in this tab appears in any other tabsets or windows." (let* ((tabset (tabbar-tab-tabset tab)) (buffer (tabbar-tab-value tab)) (tab-tabsets (tabbar-windows-per-buffer buffer)) (tabset-window-number (string-to-number (symbol-name tabset))) (buffer-windows (get-buffer-window-list buffer 'nomini t)) (tabset-window (window-number-get-window tabset-window-number))) (or (remq tabset-window-number tab-tabsets) (remq tabset-window buffer-windows)))) (defun tabbar-tabset-only-tab (tab) "Return t if this tab is the only member of its tabset, nil otherwise." (let ((buffer (tabbar-tab-value tab)) (tabset (tabbar-tab-tabset tab))) (not (remq tab (tabbar-tabs tabset))))) (defvar tabbar-retain-windows-when-tab-deleted '(not one-buffer-one-frame-mode) "Expression that evaluates to t when windows are to be retained ... after their buffer is killed.") (defun tabbar-window-delete-tab (tab) "Delete the named TAB. First check whether there are other tabs remaining in the tabset. If so, we move to the next tab if available, otherwise previous, before deleting." (let* ((tabset (tabbar-tab-tabset tab)) (wnumber (string-to-number (symbol-name (tabbar-tab-tabset tab)))) (wind (window-number-get-window wnumber)) (window-elt (assq wnumber tabbar-window-alist)) (buflist (cdr window-elt)) (buffer (tabbar-tab-value tab)) (tabbar-display-bug-workaround nil) (sel (and (eq tab (tabbar-selected-tab tabset)) ;; we need to ensure that the selected tab ;; corresponds to the currently shown buffer, ;; because we possibly haven't updated ;; the tabset since the last change ;; (e.g. find-alternate-file) (eq (window-buffer wind) (tabbar-tab-value (tabbar-selected-tab tabset)))))) ;; remove tab from tabbar-window-alist before deleting, so it won't be ;; regenerated (setq buflist (assq-delete-all buffer buflist)) ;; delete window and its member in alist if no other tabs in tabset (if (tabbar-tabset-only-tab tab) (progn (unless (eval tabbar-retain-windows-when-tab-deleted) (aquamacs-delete-window wind)) (setq tabbar-window-alist (delq window-elt tabbar-window-alist))) ;; otherwise, if this was selected tab, select the buffer that will be selected ;; by Emacs after getting killing the current buffer ;; if this one is not one of the tabs, we select an existing tab. ;; we MUST select one actively here. (when sel (with-current-buffer (current-buffer) (if (assq (other-buffer buffer nil (window-frame wind)) buflist) (progn (let ((one-buffer-one-frame)) (switch-to-buffer (other-buffer))) ;; this avoids flicker (tabbar-display-update)) (if (tabbar-tab-next tabset tab) (tabbar-click-on-tab (tabbar-tab-next tabset tab)) (tabbar-click-on-tab (tabbar-tab-next tabset tab 'before)))))) ;; put trimmed buffer list back into alist (setcdr window-elt buflist) ;; manually update tabsets now, to ensure that deleted tab is no ;; longer displayed (tabbar-window-update-tabsets) (tabbar-scroll tabset -1)))) (defun tabbar-window-close-tab (tab) "Remove tab and kill buffer if shown exclusively." ;; quit current command if in minibuffer (when (minibuffer-window-active-p (minibuffer-window (selected-frame))) (abort-recursive-edit)) (let* ((buffer (tabbar-tab-value tab)) (killable (and (killable-buffer-p buffer))) (dont-kill (tabbar-window-other-instances tab))) (when (and killable (not dont-kill)) ;; ask before killing (with-current-buffer buffer (if (and (or buffer-file-name buffer-offer-save) (buffer-modified-p)) ;; a lot of buffers (e.g. dired) may be modified, ;; but have no file name (if (aquamacs-ask-for-confirmation (format "Save buffer %s to file before closing tab? The buffer contains unsaved changes, which will be lost if you discard them now." (buffer-name)) nil (format "Save%s" (if buffer-file-name "" "...")) "Don't Save" t) (progn (if (listp last-nonmenu-event) (mac-key-save-file) (save-buffer)) (if (buffer-modified-p) (keyboard-quit) (message "File saved."))) ;; mark as not modified, so it will be killed for sure (set-buffer-modified-p nil)) (message "")))) (if (and killable (not dont-kill)) ;; 'kill-buffer-hook will call tabbar-window-delete-tab, so don't ;; do that here, unless not actually killing the buffer. (kill-buffer buffer) (tabbar-window-delete-tab tab)))) (defun tabbar-window-add-tab (tabset buffer &optional append) "Add to TABSET a tab with value BUFFER if there isn't one there yet. BUFFER must be currently live. If the tab is added, it is added at the beginning of the tab list, unless the optional argument APPEND is non-nil, in which case it is added at the end. Updates tabbar-window-alist in the same way." (let* ((wnumber (string-to-number (symbol-name tabset))) (window (window-number-get-window wnumber)) (elt (assq wnumber tabbar-window-alist)) ;; find window's tabs in tabbar-window-alist (buflist (cdr elt))) (when (and (buffer-live-p buffer) ;; only if buffer exists (not (assq buffer buflist))) ;; and not already in tabbar-window-alist (tabbar-add-tab tabset buffer append) ;; to them, add current buffer in new tab. (let ((bufpair (list buffer (buffer-name buffer) (buffer-modified-p buffer)))) (add-to-list 'buflist bufpair append) (setcdr elt buflist) ;; determine whether or not to show tabbar for this window: (if (eq (length buflist) 1) ;; if there is only 1 buffer associated with this tabset, then ;; display no tabbar (no header line). (add-to-list 'header-line-inhibit-window-list window t) ;; otherwise, ensure this window has a tabbar (setq header-line-inhibit-window-list (delq window header-line-inhibit-window-list))))))) (defun menu-bar-select-buffer (&optional buffer) (interactive) ;; if no frame visible, code below doesn't work right (why?) ;; but switch-to-buffer (its one-buffer-one-frame.el advice) will ;; bring up a good frame. To Do: delete tabs (if (and display-buffer-reuse-frames (visible-frame-list)) (let ((buffer (or buffer last-command-event))) (unless (bufferp buffer) (error "menu-bar-select-buffer: not a buffer.")) (if (visible-frame-list) ;; find a suitable window (progn (let ((w (get-window-for-other-buffer 'dont-make-frame buffer))) (if (window-live-p w) (select-window w))) ;; (set-buffer (window-buffer (selected-window))) ;; switch to buffer (may select a different window) (if tabbar-mode (switch-to-buffer-in-tab buffer) (switch-to-buffer buffer)) (select-frame-set-input-focus (window-frame (selected-window)))) ;; if no frame visible ;; find right frame and activate that one (let ((w (get-window-with-predicate (lambda (w) (eq (window-buffer w) buffer)) nil t ))) (if w (progn ; (raise-frame (window-frame w)) (make-frame-visible (window-frame w)) (select-frame-set-input-focus (window-frame w)) (select-window w) (let ((tabbar-mode nil) (one-buffer-one-frame-mode nil)) (set-window-dedicated-p w nil) (switch-to-buffer (or buffer last-command-event)))) ;; just create another frame for it (switch-to-buffer-other-frame buffer))))) (let ((previously-vis (visible-frame-list))) (switch-to-buffer (or buffer last-command-event)) (unless (memq (window-frame (selected-window)) previously-vis) ;; frame was hidden before ;; we don't want to show any leftover tabs after the switch ;; so remove the buffer tab list for that window (let ((window-alist (assq (window-number (selected-window)) tabbar-window-alist))) (setq tabbar-window-alist (delq window-alist tabbar-window-alist))))))) ;; The following shouldn't be done, because the normal switch-to-buffer ;; is not sensitive to display-buffer-reuse-frames ;; and always switches the buffer in the selected window. ;; doing what's shown below will create incompatibilities. ;; (when window-system ;; (defvar sw-in-tab-switching nil) ;; (defadvice switch-to-buffer (around sw-in-tab (&rest args) ;; activate compile protect) ;; (if (and display-buffer-reuse-frames tabbar-mode ;; (not sw-in-tab-switching)) ;; (let ((sw-in-tab-switching t)) ;; (setq ad-return-value (apply #'switch-to-buffer-in-tab args))) ;; (setq ad-return-value ad-do-it)))) (defun switch-to-buffer-in-tab (buffer &optional norecord) "Switch to BUFFER, possibly switching frames. This will display the buffer in an already-existing tab if available. Otherwise, give BUFFER a tab in the currently selected window. BUFFER may be a buffer or a string (buffer name). Optional second arg norecord non-nil means do not put this buffer at the front of the list of recently selected ones. This function returns the buffer it switched to." ;; check existing tabsets for this buffer ;; priority is for tabsets where this is currently selected tab (let* ((buf (get-buffer buffer)) (buffer-tab (or (assq buf (tabbar-map-tabsets 'tabbar-selected-tab)) (assq buf (tabbar-map-tabsets (lambda (tabset) (tabbar-get-tab buf tabset)))))) (window (window-number-get-window (string-to-number (symbol-name (tabbar-tab-tabset buffer-tab)))))) (when buf (if window (progn (set-window-buffer window buf) (select-window window norecord) (select-frame-set-input-focus (window-frame window))) (switch-to-buffer buf norecord))) buf)) (defun tabbar-window-merge-windows (&optional tabset source-tabsets) "Assign tabs from all tabsets to current tabset, or TABSET if specified, then close all other tabs and windows. Result is a single window containing all displayed buffers as tabs. Turns on tabbar-mode if not already on." (interactive) (tabbar-mode 1) (let ((tabset-keep (or tabset (tabbar-current-tabset))) (all-tabsets (or source-tabsets (mapcar 'tabbar-get-tabset (tabbar-tabset-names))))) ;; cycle through tabsets, except for current one (dolist (this-tabset all-tabsets) ;; for each tabset, cycle through buffers (unless (eq this-tabset tabset-keep) (dolist (this-tab (tabbar-tabs this-tabset)) (let ((this-buffer (tabbar-tab-value this-tab))) ;; add buffer to tabset-keep (tabbar-window-add-tab tabset-keep this-buffer t)) ;; delete tab from prior tabset (let ((tabbar-retain-windows-when-tab-deleted nil)) (tabbar-window-delete-tab this-tab))))) (unless (one-window-p 'nomini) (delete-other-windows)))) (defun tabbar-window-merge-windows-in-frame (&optional frame window) "Merges tabs from all window in a frame into a single one shown in DEST-WINDOW." (interactive) (tabbar-window-merge-windows (tabbar-window-current-tabset window) (mapcar 'tabbar-window-current-tabset (cdr-safe (window-list frame 'no-minibuf window))))) ;; exclude current window (defun tabbar-window-list-tabsets-to-save (&optional current-win) (if tabbar-current-tabset-function ;; has been initialized (let* ((tabset-names (tabbar-tabset-names)) (ntabsets (length tabset-names)) (current-tabset (tabbar-current-tabset t)) (current-tabset-name (symbol-name current-tabset)) (current-tabset-position (1- (length (member current-tabset-name (reverse tabset-names))))) (tabset-tabs (tabbar-map-tabsets 'tabbar-tabs)) (current-tabs (copy-alist (nth current-tabset-position tabset-tabs))) ;; reorder list of tabs such that current tabset's tabs are 1st (tabs-reordered (cons current-tabs (unless current-win (copy-tree (remove current-tabs tabset-tabs))))) (selected-tab-buffer (car (tabbar-selected-tab current-tabset))) tabset-save-list) ;; extract nested list of buffers in tabs (i.e. remove tabset identifiers) (setq tabset-save-list ;; loop through tabsets. For each... (mapcar (function (lambda (tabset) (remove nil ;; ... loop through tabs. Store buffer-name, or ;; set to nil if this buffer won't be restored by ;; desktop (i.e. not visiting a file, nor listed ;; in desktop-save-buffer) (mapcar (function (lambda (tab) (let ((buffer (tabbar-tab-value tab))) (setcdr tab nil) (with-current-buffer buffer (if (or (buffer-file-name buffer) desktop-save-buffer) (list 'tab (buffer-name buffer) (buffer-file-name buffer)) nil))))) tabset)))) tabs-reordered)) ;; remove nils left behind for unsaved buffers (setq tabset-save-list (remove nil tabset-save-list))) ;; ELSE (list (list (if (or (buffer-file-name) desktop-save-buffer) (list 'tab (buffer-name) (buffer-file-name)) nil))))) (defun tabbar-find-buffer (name file) (or (and file (find-buffer-visiting file)) (get-buffer name))) (defun tabbar-window-restore-tabs-in-window (tablist) ;; We do not force tabs on unless we need them. (if (or tabbar-mode ; if tabs on, always check for restorability (and tablist (> (length tablist) 1))) ; turn on tabs if tabs present (progn (unless tabbar-mode (tabbar-mode 1)) (let ((temp-tab (car (tabbar-tabs (tabbar-current-tabset t)))) (prev-tab (tabbar-selected-tab (tabbar-current-tabset))) (at-least-one-tab nil)) ;; delete tabbar here: (leads to unexplained slowdown/recursion, probably ;; when tabbar is being displayed) ;; (let* ((tabset (tabbar-current-tabset t)) ;; (wnumber (string-to-number (symbol-name tabset))) ;; (wind (window-number-get-window wnumber)) ;; (window-elt (assq wnumber tabbar-window-alist))) ;; (setcdr window-elt nil) ;; (tabbar-window-update-tabsets)) ;; create new tabs corresponding to buffer-names in saved list (dolist (spec tablist) (let ((filename) (bufname)) (if (and (consp spec) (eq 'tab (car spec))) (setq bufname (second spec) filename (third spec)) (setq bufname spec)) (let ((buffer (tabbar-find-buffer bufname filename)) (tabset (tabbar-current-tabset))) (and tabset buffer (setq at-least-one-tab t) (tabbar-window-add-tab tabset buffer t))))) (tabbar-window-delete-tab temp-tab) ;; this is insufficient. ;; t if at least one was restored at-least-one-tab)) ;; keep window if tabs turned off t)) ;; (defun tabbar-window-new-buffer (&optional mode) ;; "Create a new buffer, with different behavior depending on the value of ;; tabbar-window-new-buffers: 'tab, create new buffer in current window ;; with a new tab; 'no-tab, create new buffer in current window, with ;; no tabbar (deletes all tabs in the window); default, create new buffer ;; in new frame." ;; (cond ;; ((eq tabbar-window-new-buffers 'tab) ;; ;; create a new tab in current window ;; (tabbar-new-tab mode)) ;; ((eq tabbar-window-new-buffers 'no-tab) ;; ;; remove current window's alist from tabbar-window-alist ;; (let ((wnumber (window-number (selected-window)))) ;; (setq tabbar-window-alist (assq-delete-all wnumber tabbar-window-alist))) ;; ;; then create a new tab as usual -- lone tab will show no tabbar ;; (tabbar-new-tab mode)) ;; (t ;; ;; create a new tab in a new frame -- lone tab will show no tabbar ;; (new-frame-with-new-scratch t)))) (defun tabbar-line () "Return the header line templates that represent the tab bar. Update the templates if tabbar-template is currently nil." (tabbar-current-tabset t) (if tabbar-current-tabset (or (tabbar-template tabbar-current-tabset) (tabbar-line-format tabbar-current-tabset)))) (defun tabbar-window-current-tabset (&optional window) ;; ensure we don't count minibuffer as selected window - causes infinite loop (let* ((window (or window (minibuffer-selected-window) (selected-window))) (tabset (tabbar-get-tabset (number-to-string (window-number window))))) ;; in the case where tabs have not yet been created, tabset will still be nil ;; properly initialize all tabsets by running tabbar-window-update-tabsets (unless tabset (setq tabset (tabbar-window-update-tabsets))) (if tabset ; update may say: display no tabs at all. (tabbar-select-tab-value (window-buffer window) tabset)) tabset)) (defun tabbar-window-track-killed () "Hook function run just before actually killing a buffer. In Tabbar mode, switch to an adjacent tab if available. Delete the window if no other tabs exist. Run once for each window where current tab is displayed." (let* ((buffer (current-buffer)) (window-numbers-list (tabbar-windows-per-buffer buffer)) (upd nil)) ;; loop over all tabsets that contain a tab for this buffer (dolist (wnumber window-numbers-list) (let* ((tabset (tabbar-get-tabset (number-to-string wnumber))) (tab (tabbar-get-tab buffer tabset))) ;; ensure that tab still exists (some functions delete it ;; before killing buffer) ... (and tab ;; ... and that the tab's window still exists ... (window-number-get-window wnumber) ;; ... and that we have created all necessary tabs here ;; i.e. we don't over-zealously delete the window/frame ;; when there are actually other buffer(s) to be shown ;; as in find-alternate-file (or upd (tabbar-window-update-tabsets) (setq upd t)) ;; ... and that there is currently a tabbar ;; do not do this check: this function should ;; also remove the window if there is an alternative header line ;; (eq header-line-format tabbar-header-line-format) (tabbar-window-delete-tab tab)))))) ;;; Tab bar window setup ;; (defun tabbar-window-init () "Initialize tab bar data for tab grouping by window. Run as `tabbar-init-hook'." (setq tabbar-window-cache nil ;; keep previous tab data, if any ;; tabbar-window-alist nil tabbar-current-tabset-function 'tabbar-window-current-tabset tabbar-tab-label-function 'tabbar-window-tab-label tabbar-select-tab-function 'tabbar-window-select-tab tabbar-help-on-tab-function 'tabbar-window-help-on-tab tabbar-button-label-function 'tabbar-window-button-label tabbar-close-tab-function 'tabbar-window-close-tab tabbar-new-tab-function 'tabbar-window-new-buffer tabbar-buffer-list-function 'tabbar-window-buffer-list tabbar-home-function nil tabbar-home-help-function nil tabbar-home-button-value nil tabbar-cycle-scope 'tabs tabbar-inhibit-functions nil) (add-hook 'window-configuration-change-hook 'tabbar-window-update-tabsets-when-idle) (add-hook 'window-configuration-change-hook 'tabbar-reformat-all-tabsets) (add-hook 'first-change-hook 'tabbar-window-update-tabsets-when-idle) (add-hook 'after-undo-hook 'tabbar-update-if-changes-undone) (add-hook 'after-save-hook 'tabbar-window-update-tabsets) (add-hook 'kill-buffer-hook 'tabbar-window-track-killed) (tabbar-window-update-tabsets)) (defun tabbar-window-quit () "Quit tab bar \"tabbar-window\" mode. Run as `tabbar-quit-hook'." (setq tabbar-window-cache nil ;; keep tab data, so we can regenerate current tabs ;; if tabbar-mode is turned back on ;; tabbar-window-alist nil tabbar-current-tabset-function nil tabbar-tab-label-function nil tabbar-select-tab-function nil tabbar-help-on-tab-function nil tabbar-button-label-function nil tabbar-close-tab-function nil tabbar-new-tab-function nil tabbar-buffer-list-function nil tabbar-home-function nil tabbar-home-help-function nil tabbar-home-button-value nil tabbar-cycle-scope nil tabbar-inhibit-functions nil ) (remove-hook 'window-configuration-change-hook 'tabbar-window-update-tabsets-when-idle) (remove-hook 'window-configuration-change-hook 'tabbar-reformat-all-tabsets) (remove-hook 'first-change-hook 'tabbar-window-update-tabsets-when-idle) (remove-hook 'after-undo-hook 'tabbar-update-if-changes-undone) (remove-hook 'after-save-hook 'tabbar-window-update-tabsets) (remove-hook 'kill-buffer-hook 'tabbar-window-track-killed) ) ;;----------------------------------------------- (remove-hook 'tabbar-init-hook 'tabbar-buffer-init) (remove-hook 'tabbar-quit-hook 'tabbar-buffer-quit) (remove-hook 'kill-buffer-hook 'tabbar-buffer-track-killed) (add-hook 'tabbar-init-hook 'tabbar-window-init) (add-hook 'tabbar-quit-hook 'tabbar-window-quit) (provide 'tabbar-window) (tabbar-window-list-tabsets-to-save (selected-window)) tabbar-2.2/tabbar.el000066400000000000000000002210001332640313100143540ustar00rootroot00000000000000;; -*-no-byte-compile: t; -*- ;;; tabbar.el --- Display a tab bar in the header line ;; Copyright (C) 2003, 2004, 2005 David Ponce ;; Author: David Ponce ;; Maintainer: David Ponce ;; Created: 25 February 2003 ;; Keywords: convenience ;; Version: 2.2 ;; Revision: $Id: tabbar.el,v 1.7 2009/03/02 21:02:34 davidswelt Exp $ (defconst tabbar-version "2.2") ;; This file is not part of GNU Emacs. ;; This program is free software; you can redistribute it and/or ;; modify it under the terms of the GNU General Public License as ;; published by the Free Software Foundation; either version 3, or (at ;; your option) any later version. ;; This program is distributed in the hope that it will be useful, but ;; WITHOUT ANY WARRANTY; without even the implied warranty of ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ;; General Public License for more details. ;; You should have received a copy of the GNU General Public License ;; along with this program; see the file COPYING. If not, write to ;; the Free Software Foundation, Inc., 51 Franklin Street, Fifth ;; Floor, Boston, MA 02110-1301, USA. ;;; Commentary: ;; ;; This library provides the Tabbar global minor mode to display a tab ;; bar in the header line of Emacs 21 and later versions. You can use ;; the mouse to click on a tab and select it. Also, three buttons are ;; displayed on the left side of the tab bar in this order: the ;; "home", "scroll left", and "scroll right" buttons. The "home" ;; button is a general purpose button used to change something on the ;; tab bar. The scroll left and scroll right buttons are used to ;; scroll tabs horizontally. Tabs can be divided up into groups to ;; maintain several sets of tabs at the same time (see also the ;; chapter "Core" below for more details on tab grouping). Only one ;; group is displayed on the tab bar, and the "home" button, for ;; example, can be used to navigate through the different groups, to ;; show different tab bars. ;; ;; In a graphic environment, using the mouse is probably the preferred ;; way to work with the tab bar. However, you can also use the tab ;; bar when Emacs is running on a terminal, so it is possible to use ;; commands to press special buttons, or to navigate cyclically ;; through tabs. ;; ;; These commands, and default keyboard shortcuts, are provided: ;; ;; `tabbar-mode' ;; Toggle the Tabbar global minor mode. When enabled a tab bar is ;; displayed in the header line. ;; ;; `tabbar-local-mode' (C-c ) ;; Toggle the Tabbar-Local minor mode. Provided the global minor ;; mode is turned on, the tab bar becomes local in the current ;; buffer when the local minor mode is enabled. This permits to ;; see the tab bar in a buffer where the header line is already ;; used by another mode (like `Info-mode' for example). ;; ;; `tabbar-mwheel-mode' ;; Toggle the Tabbar-Mwheel global minor mode. When enabled you ;; can use the mouse wheel to navigate through tabs of groups. ;; ;; `tabbar-press-home' (C-c ) ;; `tabbar-press-scroll-left' (C-c ) ;; `tabbar-press-scroll-right' (C-c ) ;; Simulate a mouse-1 click on respectively the "home", "scroll ;; left", and "scroll right" buttons. A numeric prefix argument ;; value of 2, or 3, respectively simulates a mouse-2, or mouse-3 ;; click. ;; ;; `tabbar-backward' (C-c ) ;; `tabbar-forward' (C-c ) ;; Are the basic commands to navigate cyclically through tabs or ;; groups of tabs. The cycle is controlled by the ;; `tabbar-cycle-scope' option. The default is to navigate ;; through all tabs across all existing groups of tabs. You can ;; change the default behavior to navigate only through the tabs ;; visible on the tab bar, or through groups of tabs only. Or use ;; the more specialized commands below. ;; ;; `tabbar-backward-tab' ;; `tabbar-forward-tab' ;; Navigate through the tabs visible on the tab bar. ;; ;; `tabbar-backward-group' (C-c ) ;; `tabbar-forward-group' (C-c ) ;; Navigate through existing groups of tabs. ;; ;; ;; Core ;; ---- ;; ;; The content of the tab bar is represented by an internal data ;; structure: a tab set. A tab set is a collection (group) of tabs, ;; identified by an unique name. In a tab set, at any time, one and ;; only one tab is designated as selected within the tab set. ;; ;; A tab is a simple data structure giving the value of the tab, and a ;; reference to its tab set container. A tab value can be any Lisp ;; object. Each tab object is guaranteed to be unique. ;; ;; A tab set is displayed on the tab bar through a "view" defined by ;; the index of the leftmost tab shown. Thus, it is possible to ;; scroll the tab bar horizontally by changing the start index of the ;; tab set view. ;; ;; The visual representation of a tab bar is a list of valid ;; `header-line-format' template elements, one for each special ;; button, and for each tab found into a tab set "view". When the ;; visual representation of a tab is required, the function specified ;; in the variable `tabbar-tab-label-function' is called to obtain it. ;; The visual representation of a special button is obtained by ;; calling the function specified in `tabbar-button-label-function', ;; which is passed a button name among `home', `scroll-left', or ;; `scroll-right'. There are also options and faces to customize the ;; appearance of buttons and tabs (see the code for more details). ;; ;; When the mouse is over a tab, the function specified in ;; `tabbar-help-on-tab-function' is called, which is passed the tab ;; and should return a help string to display. When a tab is ;; selected, the function specified in `tabbar-select-tab-function' is ;; called, which is passed the tab and the event received. ;; ;; Similarly, to control the behavior of the special buttons, the ;; following variables are available, for respectively the `home', ;; `scroll-left' and `scroll-right' value of `