├── .gitignore ├── LICENSE.md ├── README.md ├── powerline-separators.el ├── powerline-themes.el └── powerline.el /.gitignore: -------------------------------------------------------------------------------- 1 | *.elc 2 | -------------------------------------------------------------------------------- /LICENSE.md: -------------------------------------------------------------------------------- 1 | GNU GENERAL PUBLIC LICENSE 2 | ========================== 3 | 4 | Version 3, 29 June 2007 5 | 6 | Copyright © 2007 Free Software Foundation, Inc. <> 7 | 8 | Everyone is permitted to copy and distribute verbatim copies of this license 9 | document, but changing it is not allowed. 10 | 11 | ## Preamble 12 | 13 | The GNU General Public License is a free, copyleft license for software and other 14 | kinds of works. 15 | 16 | The licenses for most software and other practical works are designed to take away 17 | your freedom to share and change the works. By contrast, the GNU General Public 18 | License is intended to guarantee your freedom to share and change all versions of a 19 | program--to make sure it remains free software for all its users. We, the Free 20 | Software Foundation, use the GNU General Public License for most of our software; it 21 | applies also to any other work released this way by its authors. You can apply it to 22 | your programs, too. 23 | 24 | When we speak of free software, we are referring to freedom, not price. Our General 25 | Public Licenses are designed to make sure that you have the freedom to distribute 26 | copies of free software (and charge for them if you wish), that you receive source 27 | code or can get it if you want it, that you can change the software or use pieces of 28 | it in new free programs, and that you know you can do these things. 29 | 30 | To protect your rights, we need to prevent others from denying you these rights or 31 | asking you to surrender the rights. Therefore, you have certain responsibilities if 32 | you distribute copies of the software, or if you modify it: responsibilities to 33 | respect the freedom of others. 34 | 35 | For example, if you distribute copies of such a program, whether gratis or for a fee, 36 | you must pass on to the recipients the same freedoms that you received. You must make 37 | sure that they, too, receive or can get the source code. And you must show them these 38 | terms so they know their rights. 39 | 40 | Developers that use the GNU GPL protect your rights with two steps: (1) assert 41 | copyright on the software, and (2) offer you this License giving you legal permission 42 | to copy, distribute and/or modify it. 43 | 44 | For the developers' and authors' protection, the GPL clearly explains that there is 45 | no warranty for this free software. For both users' and authors' sake, the GPL 46 | requires that modified versions be marked as changed, so that their problems will not 47 | be attributed erroneously to authors of previous versions. 48 | 49 | Some devices are designed to deny users access to install or run modified versions of 50 | the software inside them, although the manufacturer can do so. This is fundamentally 51 | incompatible with the aim of protecting users' freedom to change the software. The 52 | systematic pattern of such abuse occurs in the area of products for individuals to 53 | use, which is precisely where it is most unacceptable. Therefore, we have designed 54 | this version of the GPL to prohibit the practice for those products. If such problems 55 | arise substantially in other domains, we stand ready to extend this provision to 56 | those domains in future versions of the GPL, as needed to protect the freedom of 57 | users. 58 | 59 | Finally, every program is threatened constantly by software patents. States should 60 | not allow patents to restrict development and use of software on general-purpose 61 | computers, but in those that do, we wish to avoid the special danger that patents 62 | applied to a free program could make it effectively proprietary. To prevent this, the 63 | GPL assures that patents cannot be used to render the program non-free. 64 | 65 | The precise terms and conditions for copying, distribution and modification follow. 66 | 67 | ## TERMS AND CONDITIONS 68 | 69 | ### 0. Definitions. 70 | 71 | “This License” refers to version 3 of the GNU General Public License. 72 | 73 | “Copyright” also means copyright-like laws that apply to other kinds of 74 | works, such as semiconductor masks. 75 | 76 | “The Program” refers to any copyrightable work licensed under this 77 | License. Each licensee is addressed as “you”. “Licensees” and 78 | “recipients” may be individuals or organizations. 79 | 80 | To “modify” a work means to copy from or adapt all or part of the work in 81 | a fashion requiring copyright permission, other than the making of an exact copy. The 82 | resulting work is called a “modified version” of the earlier work or a 83 | work “based on” the earlier work. 84 | 85 | A “covered work” means either the unmodified Program or a work based on 86 | the Program. 87 | 88 | To “propagate” a work means to do anything with it that, without 89 | permission, would make you directly or secondarily liable for infringement under 90 | applicable copyright law, except executing it on a computer or modifying a private 91 | copy. Propagation includes copying, distribution (with or without modification), 92 | making available to the public, and in some countries other activities as well. 93 | 94 | To “convey” a work means any kind of propagation that enables other 95 | parties to make or receive copies. Mere interaction with a user through a computer 96 | network, with no transfer of a copy, is not conveying. 97 | 98 | An interactive user interface displays “Appropriate Legal Notices” to the 99 | extent that it includes a convenient and prominently visible feature that (1) 100 | displays an appropriate copyright notice, and (2) tells the user that there is no 101 | warranty for the work (except to the extent that warranties are provided), that 102 | licensees may convey the work under this License, and how to view a copy of this 103 | License. If the interface presents a list of user commands or options, such as a 104 | menu, a prominent item in the list meets this criterion. 105 | 106 | ### 1. Source Code. 107 | 108 | The “source code” for a work means the preferred form of the work for 109 | making modifications to it. “Object code” means any non-source form of a 110 | work. 111 | 112 | A “Standard Interface” means an interface that either is an official 113 | standard defined by a recognized standards body, or, in the case of interfaces 114 | specified for a particular programming language, one that is widely used among 115 | developers working in that language. 116 | 117 | The “System Libraries” of an executable work include anything, other than 118 | the work as a whole, that (a) is included in the normal form of packaging a Major 119 | Component, but which is not part of that Major Component, and (b) serves only to 120 | enable use of the work with that Major Component, or to implement a Standard 121 | Interface for which an implementation is available to the public in source code form. 122 | A “Major Component”, in this context, means a major essential component 123 | (kernel, window system, and so on) of the specific operating system (if any) on which 124 | the executable work runs, or a compiler used to produce the work, or an object code 125 | interpreter used to run it. 126 | 127 | The “Corresponding Source” for a work in object code form means all the 128 | source code needed to generate, install, and (for an executable work) run the object 129 | code and to modify the work, including scripts to control those activities. However, 130 | it does not include the work's System Libraries, or general-purpose tools or 131 | generally available free programs which are used unmodified in performing those 132 | activities but which are not part of the work. For example, Corresponding Source 133 | includes interface definition files associated with source files for the work, and 134 | the source code for shared libraries and dynamically linked subprograms that the work 135 | is specifically designed to require, such as by intimate data communication or 136 | control flow between those subprograms and other parts of the work. 137 | 138 | The Corresponding Source need not include anything that users can regenerate 139 | automatically from other parts of the Corresponding Source. 140 | 141 | The Corresponding Source for a work in source code form is that same work. 142 | 143 | ### 2. Basic Permissions. 144 | 145 | All rights granted under this License are granted for the term of copyright on the 146 | Program, and are irrevocable provided the stated conditions are met. This License 147 | explicitly affirms your unlimited permission to run the unmodified Program. The 148 | output from running a covered work is covered by this License only if the output, 149 | given its content, constitutes a covered work. This License acknowledges your rights 150 | of fair use or other equivalent, as provided by copyright law. 151 | 152 | You may make, run and propagate covered works that you do not convey, without 153 | conditions so long as your license otherwise remains in force. You may convey covered 154 | works to others for the sole purpose of having them make modifications exclusively 155 | for you, or provide you with facilities for running those works, provided that you 156 | comply with the terms of this License in conveying all material for which you do not 157 | control copyright. Those thus making or running the covered works for you must do so 158 | exclusively on your behalf, under your direction and control, on terms that prohibit 159 | them from making any copies of your copyrighted material outside their relationship 160 | with you. 161 | 162 | Conveying under any other circumstances is permitted solely under the conditions 163 | stated below. Sublicensing is not allowed; section 10 makes it unnecessary. 164 | 165 | ### 3. Protecting Users' Legal Rights From Anti-Circumvention Law. 166 | 167 | No covered work shall be deemed part of an effective technological measure under any 168 | applicable law fulfilling obligations under article 11 of the WIPO copyright treaty 169 | adopted on 20 December 1996, or similar laws prohibiting or restricting circumvention 170 | of such measures. 171 | 172 | When you convey a covered work, you waive any legal power to forbid circumvention of 173 | technological measures to the extent such circumvention is effected by exercising 174 | rights under this License with respect to the covered work, and you disclaim any 175 | intention to limit operation or modification of the work as a means of enforcing, 176 | against the work's users, your or third parties' legal rights to forbid circumvention 177 | of technological measures. 178 | 179 | ### 4. Conveying Verbatim Copies. 180 | 181 | You may convey verbatim copies of the Program's source code as you receive it, in any 182 | medium, provided that you conspicuously and appropriately publish on each copy an 183 | appropriate copyright notice; keep intact all notices stating that this License and 184 | any non-permissive terms added in accord with section 7 apply to the code; keep 185 | intact all notices of the absence of any warranty; and give all recipients a copy of 186 | this License along with the Program. 187 | 188 | You may charge any price or no price for each copy that you convey, and you may offer 189 | support or warranty protection for a fee. 190 | 191 | ### 5. Conveying Modified Source Versions. 192 | 193 | You may convey a work based on the Program, or the modifications to produce it from 194 | the Program, in the form of source code under the terms of section 4, provided that 195 | you also meet all of these conditions: 196 | 197 | * **a)** The work must carry prominent notices stating that you modified it, and giving a 198 | relevant date. 199 | * **b)** The work must carry prominent notices stating that it is released under this 200 | License and any conditions added under section 7. This requirement modifies the 201 | requirement in section 4 to “keep intact all notices”. 202 | * **c)** You must license the entire work, as a whole, under this License to anyone who 203 | comes into possession of a copy. This License will therefore apply, along with any 204 | applicable section 7 additional terms, to the whole of the work, and all its parts, 205 | regardless of how they are packaged. This License gives no permission to license the 206 | work in any other way, but it does not invalidate such permission if you have 207 | separately received it. 208 | * **d)** If the work has interactive user interfaces, each must display Appropriate Legal 209 | Notices; however, if the Program has interactive interfaces that do not display 210 | Appropriate Legal Notices, your work need not make them do so. 211 | 212 | A compilation of a covered work with other separate and independent works, which are 213 | not by their nature extensions of the covered work, and which are not combined with 214 | it such as to form a larger program, in or on a volume of a storage or distribution 215 | medium, is called an “aggregate” if the compilation and its resulting 216 | copyright are not used to limit the access or legal rights of the compilation's users 217 | beyond what the individual works permit. Inclusion of a covered work in an aggregate 218 | does not cause this License to apply to the other parts of the aggregate. 219 | 220 | ### 6. Conveying Non-Source Forms. 221 | 222 | You may convey a covered work in object code form under the terms of sections 4 and 223 | 5, provided that you also convey the machine-readable Corresponding Source under the 224 | terms of this License, in one of these ways: 225 | 226 | * **a)** Convey the object code in, or embodied in, a physical product (including a 227 | physical distribution medium), accompanied by the Corresponding Source fixed on a 228 | durable physical medium customarily used for software interchange. 229 | * **b)** Convey the object code in, or embodied in, a physical product (including a 230 | physical distribution medium), accompanied by a written offer, valid for at least 231 | three years and valid for as long as you offer spare parts or customer support for 232 | that product model, to give anyone who possesses the object code either (1) a copy of 233 | the Corresponding Source for all the software in the product that is covered by this 234 | License, on a durable physical medium customarily used for software interchange, for 235 | a price no more than your reasonable cost of physically performing this conveying of 236 | source, or (2) access to copy the Corresponding Source from a network server at no 237 | charge. 238 | * **c)** Convey individual copies of the object code with a copy of the written offer to 239 | provide the Corresponding Source. This alternative is allowed only occasionally and 240 | noncommercially, and only if you received the object code with such an offer, in 241 | accord with subsection 6b. 242 | * **d)** Convey the object code by offering access from a designated place (gratis or for 243 | a charge), and offer equivalent access to the Corresponding Source in the same way 244 | through the same place at no further charge. You need not require recipients to copy 245 | the Corresponding Source along with the object code. If the place to copy the object 246 | code is a network server, the Corresponding Source may be on a different server 247 | (operated by you or a third party) that supports equivalent copying facilities, 248 | provided you maintain clear directions next to the object code saying where to find 249 | the Corresponding Source. Regardless of what server hosts the Corresponding Source, 250 | you remain obligated to ensure that it is available for as long as needed to satisfy 251 | these requirements. 252 | * **e)** Convey the object code using peer-to-peer transmission, provided you inform 253 | other peers where the object code and Corresponding Source of the work are being 254 | offered to the general public at no charge under subsection 6d. 255 | 256 | A separable portion of the object code, whose source code is excluded from the 257 | Corresponding Source as a System Library, need not be included in conveying the 258 | object code work. 259 | 260 | A “User Product” is either (1) a “consumer product”, which 261 | means any tangible personal property which is normally used for personal, family, or 262 | household purposes, or (2) anything designed or sold for incorporation into a 263 | dwelling. In determining whether a product is a consumer product, doubtful cases 264 | shall be resolved in favor of coverage. For a particular product received by a 265 | particular user, “normally used” refers to a typical or common use of 266 | that class of product, regardless of the status of the particular user or of the way 267 | in which the particular user actually uses, or expects or is expected to use, the 268 | product. A product is a consumer product regardless of whether the product has 269 | substantial commercial, industrial or non-consumer uses, unless such uses represent 270 | the only significant mode of use of the product. 271 | 272 | “Installation Information” for a User Product means any methods, 273 | procedures, authorization keys, or other information required to install and execute 274 | modified versions of a covered work in that User Product from a modified version of 275 | its Corresponding Source. The information must suffice to ensure that the continued 276 | functioning of the modified object code is in no case prevented or interfered with 277 | solely because modification has been made. 278 | 279 | If you convey an object code work under this section in, or with, or specifically for 280 | use in, a User Product, and the conveying occurs as part of a transaction in which 281 | the right of possession and use of the User Product is transferred to the recipient 282 | in perpetuity or for a fixed term (regardless of how the transaction is 283 | characterized), the Corresponding Source conveyed under this section must be 284 | accompanied by the Installation Information. But this requirement does not apply if 285 | neither you nor any third party retains the ability to install modified object code 286 | on the User Product (for example, the work has been installed in ROM). 287 | 288 | The requirement to provide Installation Information does not include a requirement to 289 | continue to provide support service, warranty, or updates for a work that has been 290 | modified or installed by the recipient, or for the User Product in which it has been 291 | modified or installed. Access to a network may be denied when the modification itself 292 | materially and adversely affects the operation of the network or violates the rules 293 | and protocols for communication across the network. 294 | 295 | Corresponding Source conveyed, and Installation Information provided, in accord with 296 | this section must be in a format that is publicly documented (and with an 297 | implementation available to the public in source code form), and must require no 298 | special password or key for unpacking, reading or copying. 299 | 300 | ### 7. Additional Terms. 301 | 302 | “Additional permissions” are terms that supplement the terms of this 303 | License by making exceptions from one or more of its conditions. Additional 304 | permissions that are applicable to the entire Program shall be treated as though they 305 | were included in this License, to the extent that they are valid under applicable 306 | law. If additional permissions apply only to part of the Program, that part may be 307 | used separately under those permissions, but the entire Program remains governed by 308 | this License without regard to the additional permissions. 309 | 310 | When you convey a copy of a covered work, you may at your option remove any 311 | additional permissions from that copy, or from any part of it. (Additional 312 | permissions may be written to require their own removal in certain cases when you 313 | modify the work.) You may place additional permissions on material, added by you to a 314 | covered work, for which you have or can give appropriate copyright permission. 315 | 316 | Notwithstanding any other provision of this License, for material you add to a 317 | covered work, you may (if authorized by the copyright holders of that material) 318 | supplement the terms of this License with terms: 319 | 320 | * **a)** Disclaiming warranty or limiting liability differently from the terms of 321 | sections 15 and 16 of this License; or 322 | * **b)** Requiring preservation of specified reasonable legal notices or author 323 | attributions in that material or in the Appropriate Legal Notices displayed by works 324 | containing it; or 325 | * **c)** Prohibiting misrepresentation of the origin of that material, or requiring that 326 | modified versions of such material be marked in reasonable ways as different from the 327 | original version; or 328 | * **d)** Limiting the use for publicity purposes of names of licensors or authors of the 329 | material; or 330 | * **e)** Declining to grant rights under trademark law for use of some trade names, 331 | trademarks, or service marks; or 332 | * **f)** Requiring indemnification of licensors and authors of that material by anyone 333 | who conveys the material (or modified versions of it) with contractual assumptions of 334 | liability to the recipient, for any liability that these contractual assumptions 335 | directly impose on those licensors and authors. 336 | 337 | All other non-permissive additional terms are considered “further 338 | restrictions” within the meaning of section 10. If the Program as you received 339 | it, or any part of it, contains a notice stating that it is governed by this License 340 | along with a term that is a further restriction, you may remove that term. If a 341 | license document contains a further restriction but permits relicensing or conveying 342 | under this License, you may add to a covered work material governed by the terms of 343 | that license document, provided that the further restriction does not survive such 344 | relicensing or conveying. 345 | 346 | If you add terms to a covered work in accord with this section, you must place, in 347 | the relevant source files, a statement of the additional terms that apply to those 348 | files, or a notice indicating where to find the applicable terms. 349 | 350 | Additional terms, permissive or non-permissive, may be stated in the form of a 351 | separately written license, or stated as exceptions; the above requirements apply 352 | either way. 353 | 354 | ### 8. Termination. 355 | 356 | You may not propagate or modify a covered work except as expressly provided under 357 | this License. Any attempt otherwise to propagate or modify it is void, and will 358 | automatically terminate your rights under this License (including any patent licenses 359 | granted under the third paragraph of section 11). 360 | 361 | However, if you cease all violation of this License, then your license from a 362 | particular copyright holder is reinstated (a) provisionally, unless and until the 363 | copyright holder explicitly and finally terminates your license, and (b) permanently, 364 | if the copyright holder fails to notify you of the violation by some reasonable means 365 | prior to 60 days after the cessation. 366 | 367 | Moreover, your license from a particular copyright holder is reinstated permanently 368 | if the copyright holder notifies you of the violation by some reasonable means, this 369 | is the first time you have received notice of violation of this License (for any 370 | work) from that copyright holder, and you cure the violation prior to 30 days after 371 | your receipt of the notice. 372 | 373 | Termination of your rights under this section does not terminate the licenses of 374 | parties who have received copies or rights from you under this License. If your 375 | rights have been terminated and not permanently reinstated, you do not qualify to 376 | receive new licenses for the same material under section 10. 377 | 378 | ### 9. Acceptance Not Required for Having Copies. 379 | 380 | You are not required to accept this License in order to receive or run a copy of the 381 | Program. Ancillary propagation of a covered work occurring solely as a consequence of 382 | using peer-to-peer transmission to receive a copy likewise does not require 383 | acceptance. However, nothing other than this License grants you permission to 384 | propagate or modify any covered work. These actions infringe copyright if you do not 385 | accept this License. Therefore, by modifying or propagating a covered work, you 386 | indicate your acceptance of this License to do so. 387 | 388 | ### 10. Automatic Licensing of Downstream Recipients. 389 | 390 | Each time you convey a covered work, the recipient automatically receives a license 391 | from the original licensors, to run, modify and propagate that work, subject to this 392 | License. You are not responsible for enforcing compliance by third parties with this 393 | License. 394 | 395 | An “entity transaction” is a transaction transferring control of an 396 | organization, or substantially all assets of one, or subdividing an organization, or 397 | merging organizations. If propagation of a covered work results from an entity 398 | transaction, each party to that transaction who receives a copy of the work also 399 | receives whatever licenses to the work the party's predecessor in interest had or 400 | could give under the previous paragraph, plus a right to possession of the 401 | Corresponding Source of the work from the predecessor in interest, if the predecessor 402 | has it or can get it with reasonable efforts. 403 | 404 | You may not impose any further restrictions on the exercise of the rights granted or 405 | affirmed under this License. For example, you may not impose a license fee, royalty, 406 | or other charge for exercise of rights granted under this License, and you may not 407 | initiate litigation (including a cross-claim or counterclaim in a lawsuit) alleging 408 | that any patent claim is infringed by making, using, selling, offering for sale, or 409 | importing the Program or any portion of it. 410 | 411 | ### 11. Patents. 412 | 413 | A “contributor” is a copyright holder who authorizes use under this 414 | License of the Program or a work on which the Program is based. The work thus 415 | licensed is called the contributor's “contributor version”. 416 | 417 | A contributor's “essential patent claims” are all patent claims owned or 418 | controlled by the contributor, whether already acquired or hereafter acquired, that 419 | would be infringed by some manner, permitted by this License, of making, using, or 420 | selling its contributor version, but do not include claims that would be infringed 421 | only as a consequence of further modification of the contributor version. For 422 | purposes of this definition, “control” includes the right to grant patent 423 | sublicenses in a manner consistent with the requirements of this License. 424 | 425 | Each contributor grants you a non-exclusive, worldwide, royalty-free patent license 426 | under the contributor's essential patent claims, to make, use, sell, offer for sale, 427 | import and otherwise run, modify and propagate the contents of its contributor 428 | version. 429 | 430 | In the following three paragraphs, a “patent license” is any express 431 | agreement or commitment, however denominated, not to enforce a patent (such as an 432 | express permission to practice a patent or covenant not to sue for patent 433 | infringement). To “grant” such a patent license to a party means to make 434 | such an agreement or commitment not to enforce a patent against the party. 435 | 436 | If you convey a covered work, knowingly relying on a patent license, and the 437 | Corresponding Source of the work is not available for anyone to copy, free of charge 438 | and under the terms of this License, through a publicly available network server or 439 | other readily accessible means, then you must either (1) cause the Corresponding 440 | Source to be so available, or (2) arrange to deprive yourself of the benefit of the 441 | patent license for this particular work, or (3) arrange, in a manner consistent with 442 | the requirements of this License, to extend the patent license to downstream 443 | recipients. “Knowingly relying” means you have actual knowledge that, but 444 | for the patent license, your conveying the covered work in a country, or your 445 | recipient's use of the covered work in a country, would infringe one or more 446 | identifiable patents in that country that you have reason to believe are valid. 447 | 448 | If, pursuant to or in connection with a single transaction or arrangement, you 449 | convey, or propagate by procuring conveyance of, a covered work, and grant a patent 450 | license to some of the parties receiving the covered work authorizing them to use, 451 | propagate, modify or convey a specific copy of the covered work, then the patent 452 | license you grant is automatically extended to all recipients of the covered work and 453 | works based on it. 454 | 455 | A patent license is “discriminatory” if it does not include within the 456 | scope of its coverage, prohibits the exercise of, or is conditioned on the 457 | non-exercise of one or more of the rights that are specifically granted under this 458 | License. You may not convey a covered work if you are a party to an arrangement with 459 | a third party that is in the business of distributing software, under which you make 460 | payment to the third party based on the extent of your activity of conveying the 461 | work, and under which the third party grants, to any of the parties who would receive 462 | the covered work from you, a discriminatory patent license (a) in connection with 463 | copies of the covered work conveyed by you (or copies made from those copies), or (b) 464 | primarily for and in connection with specific products or compilations that contain 465 | the covered work, unless you entered into that arrangement, or that patent license 466 | was granted, prior to 28 March 2007. 467 | 468 | Nothing in this License shall be construed as excluding or limiting any implied 469 | license or other defenses to infringement that may otherwise be available to you 470 | under applicable patent law. 471 | 472 | ### 12. No Surrender of Others' Freedom. 473 | 474 | If conditions are imposed on you (whether by court order, agreement or otherwise) 475 | that contradict the conditions of this License, they do not excuse you from the 476 | conditions of this License. If you cannot convey a covered work so as to satisfy 477 | simultaneously your obligations under this License and any other pertinent 478 | obligations, then as a consequence you may not convey it at all. For example, if you 479 | agree to terms that obligate you to collect a royalty for further conveying from 480 | those to whom you convey the Program, the only way you could satisfy both those terms 481 | and this License would be to refrain entirely from conveying the Program. 482 | 483 | ### 13. Use with the GNU Affero General Public License. 484 | 485 | Notwithstanding any other provision of this License, you have permission to link or 486 | combine any covered work with a work licensed under version 3 of the GNU Affero 487 | General Public License into a single combined work, and to convey the resulting work. 488 | The terms of this License will continue to apply to the part which is the covered 489 | work, but the special requirements of the GNU Affero General Public License, section 490 | 13, concerning interaction through a network will apply to the combination as such. 491 | 492 | ### 14. Revised Versions of this License. 493 | 494 | The Free Software Foundation may publish revised and/or new versions of the GNU 495 | General Public License from time to time. Such new versions will be similar in spirit 496 | to the present version, but may differ in detail to address new problems or concerns. 497 | 498 | Each version is given a distinguishing version number. If the Program specifies that 499 | a certain numbered version of the GNU General Public License “or any later 500 | version” applies to it, you have the option of following the terms and 501 | conditions either of that numbered version or of any later version published by the 502 | Free Software Foundation. If the Program does not specify a version number of the GNU 503 | General Public License, you may choose any version ever published by the Free 504 | Software Foundation. 505 | 506 | If the Program specifies that a proxy can decide which future versions of the GNU 507 | General Public License can be used, that proxy's public statement of acceptance of a 508 | version permanently authorizes you to choose that version for the Program. 509 | 510 | Later license versions may give you additional or different permissions. However, no 511 | additional obligations are imposed on any author or copyright holder as a result of 512 | your choosing to follow a later version. 513 | 514 | ### 15. Disclaimer of Warranty. 515 | 516 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. 517 | EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES 518 | PROVIDE THE PROGRAM “AS IS” WITHOUT WARRANTY OF ANY KIND, EITHER 519 | EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 520 | MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE 521 | QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE 522 | DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 523 | 524 | ### 16. Limitation of Liability. 525 | 526 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY 527 | COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS THE PROGRAM AS 528 | PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, 529 | INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE 530 | PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE 531 | OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE 532 | WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE 533 | POSSIBILITY OF SUCH DAMAGES. 534 | 535 | ### 17. Interpretation of Sections 15 and 16. 536 | 537 | If the disclaimer of warranty and limitation of liability provided above cannot be 538 | given local legal effect according to their terms, reviewing courts shall apply local 539 | law that most closely approximates an absolute waiver of all civil liability in 540 | connection with the Program, unless a warranty or assumption of liability accompanies 541 | a copy of the Program in return for a fee. 542 | 543 | END OF TERMS AND CONDITIONS 544 | 545 | ## How to Apply These Terms to Your New Programs 546 | 547 | If you develop a new program, and you want it to be of the greatest possible use to 548 | the public, the best way to achieve this is to make it free software which everyone 549 | can redistribute and change under these terms. 550 | 551 | To do so, attach the following notices to the program. It is safest to attach them 552 | to the start of each source file to most effectively state the exclusion of warranty; 553 | and each file should have at least the “copyright” line and a pointer to 554 | where the full notice is found. 555 | 556 | 557 | Copyright (C) 558 | 559 | This program is free software: you can redistribute it and/or modify 560 | it under the terms of the GNU General Public License as published by 561 | the Free Software Foundation, either version 3 of the License, or 562 | (at your option) any later version. 563 | 564 | This program is distributed in the hope that it will be useful, 565 | but WITHOUT ANY WARRANTY; without even the implied warranty of 566 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 567 | GNU General Public License for more details. 568 | 569 | You should have received a copy of the GNU General Public License 570 | along with this program. If not, see . 571 | 572 | Also add information on how to contact you by electronic and paper mail. 573 | 574 | If the program does terminal interaction, make it output a short notice like this 575 | when it starts in an interactive mode: 576 | 577 | Copyright (C) 578 | This program comes with ABSOLUTELY NO WARRANTY; for details type 'show w'. 579 | This is free software, and you are welcome to redistribute it 580 | under certain conditions; type 'show c' for details. 581 | 582 | The hypothetical commands 'show w' and 'show c' should show the appropriate parts of 583 | the General Public License. Of course, your program's commands might be different; 584 | for a GUI interface, you would use an “about box”. 585 | 586 | You should also get your employer (if you work as a programmer) or school, if any, to 587 | sign a “copyright disclaimer” for the program, if necessary. For more 588 | information on this, and how to apply and follow the GNU GPL, see 589 | <>. 590 | 591 | The GNU General Public License does not permit incorporating your program into 592 | proprietary programs. If your program is a subroutine library, you may consider it 593 | more useful to permit linking proprietary applications with the library. If this is 594 | what you want to do, use the GNU Lesser General Public License instead of this 595 | License. But first, please read 596 | <>. -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | powerline 2 | ========= 3 | 4 | ***NOTE:** This project is in maintenance mode and not currently being developed or maintained. Pull requests will be reviewed and accepted but may not get 5 | an immediate response. Sorry for the inconvenience.* 6 | 7 | Emacs version of the Vim powerline. 8 | 9 | This is a proposed version 2.0 of the original [Emacs Powerline](http://www.emacswiki.org/emacs/PowerLine) which is a fork of [vim-powerline](https://github.com/Lokaltog/vim-powerline). 10 | 11 | This version has utf-8 support enabled. The `utf-8` separators will display a unicode character properly under mintty for example - as long as you have [patched fonts](https://github.com/Lokaltog/powerline-fonts) installed. 12 | 13 | By default, any terminal mode emacs will use the `utf-8` separators. 14 | 15 | ## Installation 16 | 17 | (require 'powerline) 18 | (powerline-default-theme) 19 | 20 | The second line customizes `mode-line-format` according to the default theme. 21 | 22 | There are five builtin themes: 23 | - `powerline-default-theme` 24 | - `powerline-center-theme` 25 | - `powerline-center-evil-theme` 26 | - `powerline-vim-theme` 27 | - `powerline-nano-theme` 28 | 29 | You can revert back to the original value of `mode-line-format` that was being used when powerline was loaded using `powerline-revert`. 30 | 31 | ## Faces 32 | 33 | The faces that powerline uses for the builtin themes are `powerline-active1` and `powerline-active2` for the active modeline, and `powerline-inactive1` ande `powerline-inactive2` for the inactive modelines. If you create your own theme, you can add as many faces as you want and pass those faces to the corresponding `powerline-*` functions when creating your `mode-line-format`. 34 | 35 | 36 | ## Custom Themes 37 | 38 | Please look over the `powerline-default-theme` and `powerline-center-theme` in [`powerline-themes.el`](https://github.com/milkypostman/powerline/blob/master/powerline-themes.el) for examples of themes that involve different justifications of modeline text. 39 | 40 | You can write your own powerline theme by simply setting your own `mode-line-format` to be an evaluation (`:eval`) of the powerline functions. Notice in `powerline-default-theme` the `let*` defines two lists: `lhs` and `rhs` which are exactly the lists that define what goes on the left and right sides of the modeline. The `powerline-center-theme` demonstrates how to *center* justify part of the modeline and defines an additional `center` list which is exactly the modeline components to be displayed in the middle section. 41 | 42 | In *most* circumstances you should only need to modify the builtin themes unless you are trying to do a particularly unique layout. 43 | 44 | 45 | ### Explanation 46 | 47 | This theme does some tricks to improve performance and get all the text justified properly. First, it sets `lhs` and `rhs` to a list of powerline sections. You can easily re-utilize builtin modeline formatting by adding it as a raw powerline section. For example, 48 | 49 | (powerline-raw mode-line-mule-info nil 'l) 50 | 51 | would add the formatting defined in `mode-line-mule-info` to the modeline as it appears in the default modeline. 52 | 53 | The last line of this is what actually puts it all together, by concatonating the `lhs`, some "fill" space, and `rhs`. This *must* be done to ensure that the padding in between the left and right sections properly fills the modeline. 54 | 55 | 56 | 57 | ## Improvements from this rewrite: 58 | 59 | * Cleaner code. 60 | * Try to simply be a *library* that provides functions for generating a mode-line 61 | * Make right-aligned text actually be flush against the right side. 62 | * Separators are designed to dynamically size their height based on the font settings. 63 | * Separators spread their width to the nearest character width. (This is required to make right-aligned text actually be right-aligned) 64 | 65 | 66 | ## Implementing New Separators 67 | 68 | The function should return an XPM image created using the `create-image` function. 69 | 70 | There is a function called `memoize` that will help make calling the function multiple times with the same parameters be much quicker by caching the return value. 71 | 72 | Each divider should have the signature: `(face1 face2 &optional height)` 73 | 74 | `face1` : the left-hand face 75 | 76 | `face2` : the right-hand face 77 | 78 | `height` : specifies the height of the XPM, most of time this is `(font-char-height)` 79 | 80 | Separators should consider the `height` when they are created so that the mode-line can change sizes based on the font height. 81 | 82 | -------------------------------------------------------------------------------- /powerline-separators.el: -------------------------------------------------------------------------------- 1 | ;;; powerline-separators.el --- Separators for Powerline 2 | 3 | ;; Copyright (C) 2012-2013 Donald Ephraim Curtis 4 | ;; Copyright (C) 2013 Jason Milkins 5 | ;; Copyright (C) 2012 Nicolas Rougier 6 | 7 | ;; This file is free software; you can redistribute it and/or modify 8 | ;; it under the terms of the GNU General Public License as published by 9 | ;; the Free Software Foundation; either version 3, or (at your option) 10 | ;; any later version. 11 | 12 | ;; This file is distributed in the hope that it will be useful, 13 | ;; but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | ;; GNU General Public License for more details. 16 | 17 | ;; You should have received a copy of the GNU General Public License 18 | ;; along with this program. If not, see . 19 | 20 | ;;; Commentary: 21 | ;; 22 | ;; Separators for Powerline. 23 | ;; Included separators: alternate, arrow, arrow-fade, bar, box, brace, butt, 24 | ;; chamfer, contour, curve, rounded, roundstub, slant, wave, zigzag, and nil. 25 | ;; 26 | 27 | ;;; Code: 28 | 29 | (require 'cl-lib) 30 | (require 'color) 31 | (require 'ring) 32 | 33 | (defvar powerline-image-apple-rgb 34 | (and (eq (window-system) 'ns) 35 | (bound-and-true-p ns-use-srgb-colorspace) 36 | (< 11 37 | (string-to-number 38 | (save-match-data 39 | (and (string-match "darwin\\([0-9]+\\)" system-configuration) 40 | (match-string-no-properties 1 system-configuration))))) 41 | (< emacs-major-version 28)) 42 | "If non-nil, use Apple RGB colorspace to render images. 43 | 44 | t on macOS 10.7+ and `ns-use-srgb-colorspace' is t, nil otherwise. 45 | 46 | This variable is automatically set, there's no need to modify it. 47 | 48 | Obsolete since Emacs 28.") 49 | 50 | (defun pl/interpolate (color1 color2) 51 | "Interpolate between COLOR1 and COLOR2. 52 | 53 | COLOR1 and COLOR2 must be supplied as hex strings with a leading #." 54 | (let* ((c1 (color-name-to-rgb color1)) 55 | (c2 (color-name-to-rgb color2)) 56 | (red (/ (+ (nth 0 c1) (nth 0 c2)) 2)) 57 | (green (/ (+ (nth 1 c1) (nth 1 c2)) 2)) 58 | (blue (/ (+ (nth 2 c1) (nth 2 c2)) 2))) 59 | (color-rgb-to-hex red green blue))) 60 | 61 | (defun pl/color-xyz-to-apple-rgb (X Y Z) 62 | "Convert CIE X Y Z colors to Apple RGB color space." 63 | (let ((r (+ (* 3.2404542 X) (* -1.5371385 Y) (* -0.4985314 Z))) 64 | (g (+ (* -0.9692660 X) (* 1.8760108 Y) (* 0.0415560 Z))) 65 | (b (+ (* 0.0556434 X) (* -0.2040259 Y) (* 1.0572252 Z)))) 66 | (list (expt r (/ 1.8)) (expt g (/ 1.8)) (expt b (/ 1.8))))) 67 | 68 | (defun pl/color-srgb-to-apple-rgb (red green blue) 69 | "Convert RED GREEN BLUE colors from sRGB color space to Apple RGB. 70 | RED, GREEN and BLUE should be between 0.0 and 1.0, inclusive." 71 | (apply 'pl/color-xyz-to-apple-rgb (color-srgb-to-xyz red green blue))) 72 | 73 | (defun pl/hex-color (color) 74 | "Get the hexadecimal value of COLOR." 75 | (when color 76 | (let ((srgb-color (color-name-to-rgb color))) 77 | (if powerline-image-apple-rgb 78 | (apply 'color-rgb-to-hex (apply 'pl/color-srgb-to-apple-rgb srgb-color)) 79 | (apply 'color-rgb-to-hex srgb-color))))) 80 | 81 | (defun pl/pattern (lst) 82 | "Turn LST into an infinite pattern." 83 | (when lst 84 | (ring-convert-sequence-to-ring lst))) 85 | 86 | (defun pl/pattern-to-string (pattern) 87 | "Convert a PATTERN into a string that can be used in an XPM." 88 | (concat "\"" (mapconcat 'number-to-string pattern "") "\",")) 89 | 90 | (defun pl/reverse-pattern (pattern) 91 | "Reverse each line in PATTERN." 92 | (mapcar 'reverse pattern)) 93 | 94 | (defun pl/row-pattern (fill total &optional fade) 95 | "Return list that has FILL 0s out of TOTAL 1s with FADE 2s to the right." 96 | (unless fade 97 | (setq fade 0)) 98 | (let ((fill (min fill total)) 99 | (fade (min fade (max (- total fill) 0)))) 100 | (nconc (make-list fill 0) 101 | (make-list fade 2) 102 | (make-list (- total fill fade) 1)))) 103 | 104 | (defun pl/pattern-bindings-body (patterns height-exp pattern-height-sym 105 | second-pattern-height-sym) 106 | "Create let-var bindings and a function body from PATTERNS. 107 | The `car' and `cdr' parts of the result can be passed to the 108 | function `pl/wrap-defun' as its `let-vars' and `body' arguments, 109 | respectively. HEIGHT-EXP is an expression calculating the image 110 | height and it should contain a free variable `height'. 111 | PATTERN-HEIGHT-SYM and SECOND-PATTERN-HEIGHT-SYM are symbols used 112 | for let-var binding variables." 113 | (let* ((pattern (pl/pattern (mapcar 'pl/pattern-to-string (car patterns)))) 114 | (header (mapcar 'pl/pattern-to-string (nth 1 patterns))) 115 | (footer (mapcar 'pl/pattern-to-string (nth 2 patterns))) 116 | (second-pattern (pl/pattern (mapcar 'pl/pattern-to-string (nth 3 patterns)))) 117 | (center (mapcar 'pl/pattern-to-string (nth 4 patterns))) 118 | (reserve (+ (length header) (length footer) (length center)))) 119 | (when pattern 120 | (cons `((,pattern-height-sym (max (- ,height-exp ,reserve) 0)) 121 | (,second-pattern-height-sym (/ ,pattern-height-sym 2)) 122 | (,pattern-height-sym ,(if second-pattern `(ceiling ,pattern-height-sym 2) `,pattern-height-sym))) 123 | (list (when header `(apply 'concat ',header)) 124 | `(cl-loop for i to ,pattern-height-sym 125 | concat (ring-ref ',pattern i)) 126 | (when center `(apply 'concat ',center)) 127 | (when second-pattern 128 | `(cl-loop for i to ,second-pattern-height-sym 129 | concat (ring-ref ',second-pattern i))) 130 | (when footer `(apply 'concat ',footer))))))) 131 | 132 | (defun pl/pattern-defun (name dir width &rest patterns) 133 | "Create a powerline function of NAME in DIR with WIDTH for PATTERNS. 134 | 135 | PATTERNS is of the form (PATTERN HEADER FOOTER SECOND-PATTERN CENTER 136 | PATTERN-2X HEADER-2X FOOTER-2X SECOND-PATTERN-2X CENTER-2X). 137 | PATTERN is required, all other components are optional. 138 | The first 5 components are for the standard resolution image. 139 | The remaining ones are for the high resolution image where both 140 | width and height are doubled. If PATTERN-2X is nil or not given, 141 | then the remaining components are ignored and the standard 142 | resolution image with magnification and interpolation will be 143 | used in high resolution environments 144 | 145 | All generated functions generate the form: 146 | HEADER 147 | PATTERN ... 148 | CENTER 149 | SECOND-PATTERN ... 150 | FOOTER 151 | 152 | PATTERN and SECOND-PATTERN repeat infinitely to fill the space 153 | needed to generate a full height XPM. 154 | 155 | PATTERN, HEADER, FOOTER, SECOND-PATTERN, CENTER are of the 156 | form ((COLOR ...) (COLOR ...) ...). 157 | 158 | COLOR can be one of 0, 1, or 2, where 0 is the source color, 1 is 159 | the destination color, and 2 is the interpolated color between 0 160 | and 1." 161 | (when (eq dir 'right) 162 | (setq patterns (mapcar 'pl/reverse-pattern patterns))) 163 | (let ((bindings-body (pl/pattern-bindings-body patterns 164 | 'height 165 | 'pattern-height 166 | 'second-pattern-height)) 167 | (bindings-body-2x (pl/pattern-bindings-body (nthcdr 5 patterns) 168 | '(* height 2) 169 | 'pattern-height-2x 170 | 'second-pattern-height-2x))) 171 | (pl/wrap-defun name dir width 172 | (append (car bindings-body) (car bindings-body-2x)) 173 | (cdr bindings-body) (cdr bindings-body-2x)))) 174 | 175 | (defun pl/background-color (face) 176 | (face-attribute face 177 | (if (face-attribute face :inverse-video nil 'default) 178 | :foreground 179 | :background) 180 | nil 181 | 'default)) 182 | 183 | (defun pl/wrap-defun (name dir width let-vars body &optional body-2x) 184 | "Generate a powerline function of NAME in DIR with WIDTH using LET-VARS and BODY." 185 | (let* ((src-face (if (eq dir 'left) 'face1 'face2)) 186 | (dst-face (if (eq dir 'left) 'face2 'face1))) 187 | `(defun ,(intern (format "powerline-%s-%s" name (symbol-name dir))) 188 | (face1 face2 &optional height) 189 | (when window-system 190 | (unless height (setq height (pl/separator-height))) 191 | (let* ,(append `((color1 (when ,src-face 192 | (pl/hex-color (pl/background-color ,src-face)))) 193 | (color2 (when ,dst-face 194 | (pl/hex-color (pl/background-color ,dst-face)))) 195 | (colori (when (and color1 color2) (pl/interpolate color1 color2))) 196 | (color1 (or color1 "None")) 197 | (color2 (or color2 "None")) 198 | (colori (or colori "None"))) 199 | let-vars) 200 | (apply 'create-image 201 | ,(append `(concat (format "/* XPM */ static char * %s_%s[] = { \"%s %s 3 1\", \"0 c %s\", \"1 c %s\", \"2 c %s\"," 202 | ,(replace-regexp-in-string "-" "_" name) 203 | (symbol-name ',dir) 204 | ,width 205 | height 206 | color1 207 | color2 208 | colori)) 209 | body 210 | '("};")) 211 | 'xpm t 212 | :ascent 'center 213 | :scale 1 214 | :face (when (and face1 face2) 215 | ,dst-face) 216 | ,(and body-2x 217 | `(and (featurep 'mac) 218 | (list :data-2x 219 | ,(append `(concat (format "/* XPM */ static char * %s_%s_2x[] = { \"%s %s 3 1\", \"0 c %s\", \"1 c %s\", \"2 c %s\"," 220 | ,(replace-regexp-in-string "-" "_" name) 221 | (symbol-name ',dir) 222 | (* ,width 2) 223 | (* height 2) 224 | color1 225 | color2 226 | colori)) 227 | body-2x 228 | '("};"))))))))))) 229 | 230 | (defmacro pl/alternate (dir) 231 | "Generate an alternating pattern XPM function for DIR." 232 | (pl/pattern-defun "alternate" dir 4 233 | '((2 2 1 1) 234 | (0 0 2 2)) 235 | nil nil nil nil 236 | ;; 2x 237 | '((2 2 2 2 1 1 1 1) 238 | (2 2 2 2 1 1 1 1) 239 | (0 0 0 0 2 2 2 2) 240 | (0 0 0 0 2 2 2 2)))) 241 | 242 | (defmacro pl/arrow (dir) 243 | "Generate an arrow XPM function for DIR." 244 | (let ((row-modifier (if (eq dir 'left) 'identity 'reverse))) 245 | (pl/wrap-defun "arrow" dir 'middle-width 246 | '((width (1- (/ height 2))) 247 | (middle-width (1- (ceiling height 2)))) 248 | `((cl-loop for i from 0 to width 249 | concat (pl/pattern-to-string (,row-modifier (pl/row-pattern i middle-width)))) 250 | (when (cl-oddp height) 251 | (pl/pattern-to-string (make-list middle-width 0))) 252 | (cl-loop for i from width downto 0 253 | concat (pl/pattern-to-string (,row-modifier (pl/row-pattern i middle-width))))) 254 | `((when (cl-evenp height) 255 | (pl/pattern-to-string (make-list (* middle-width 2) 1))) 256 | (cl-loop for i from 0 to (* middle-width 2) 257 | concat (pl/pattern-to-string (,row-modifier (pl/row-pattern i (* middle-width 2))))) 258 | (cl-loop for i from (* middle-width 2) downto 0 259 | concat (pl/pattern-to-string (,row-modifier (pl/row-pattern i (* middle-width 2))))) 260 | (when (cl-evenp height) 261 | (pl/pattern-to-string (make-list (* middle-width 2) 1))))))) 262 | 263 | (defmacro pl/arrow-fade (dir) 264 | "Generate an arrow-fade XPM function for DIR." 265 | (let* ((row-modifier (if (eq dir 'left) 'identity 'reverse))) 266 | (pl/wrap-defun "arrow-fade" dir 'middle-width 267 | '((width (1- (/ height 2))) 268 | (middle-width (1+ (ceiling height 2)))) 269 | `((cl-loop for i from 0 to width 270 | concat (pl/pattern-to-string (,row-modifier (pl/row-pattern i middle-width 2)))) 271 | (when (cl-oddp height) 272 | (pl/pattern-to-string (,row-modifier (pl/row-pattern (1+ width) middle-width 2)))) 273 | (cl-loop for i from width downto 0 274 | concat (pl/pattern-to-string (,row-modifier (pl/row-pattern i middle-width 2))))) 275 | `((when (cl-evenp height) 276 | (pl/pattern-to-string (,row-modifier (pl/row-pattern 0 (* middle-width 2) (* 2 2))))) 277 | (cl-loop for i from 0 to (* (- middle-width 2) 2) 278 | concat (pl/pattern-to-string (,row-modifier (pl/row-pattern i (* middle-width 2) (* 2 2))))) 279 | (cl-loop for i from (* (- middle-width 2) 2) downto 0 280 | concat (pl/pattern-to-string (,row-modifier (pl/row-pattern i (* middle-width 2) (* 2 2))))) 281 | (when (cl-evenp height) 282 | (pl/pattern-to-string (,row-modifier (pl/row-pattern 0 (* middle-width 2) (* 2 2))))))))) 283 | 284 | (defmacro pl/bar (dir) 285 | "Generate a bar XPM function for DIR." 286 | (pl/pattern-defun "bar" dir 2 287 | '((2 2)))) 288 | 289 | (defmacro pl/box (dir) 290 | "Generate a box XPM function for DIR." 291 | (pl/pattern-defun "box" dir 2 292 | '((0 0) 293 | (0 0) 294 | (1 1) 295 | (1 1)) 296 | nil nil nil nil 297 | ;; 2x 298 | '((0 0 0 0) 299 | (0 0 0 0) 300 | (0 0 0 0) 301 | (0 0 0 0) 302 | (1 1 1 1) 303 | (1 1 1 1) 304 | (1 1 1 1) 305 | (1 1 1 1)))) 306 | 307 | (defmacro pl/brace (dir) 308 | "Generate a brace XPM function for DIR." 309 | (pl/pattern-defun "brace" dir 4 310 | '((0 1 1 1)) 311 | '((1 1 1 1) 312 | (2 1 1 1)) 313 | '((2 1 1 1) 314 | (1 1 1 1)) 315 | '((0 1 1 1)) 316 | '((0 2 1 1) 317 | (0 2 1 1) 318 | (0 0 2 1) 319 | (0 0 0 0) 320 | (0 0 2 1) 321 | (0 2 1 1) 322 | (0 2 1 1)) 323 | ;; 2x 324 | '((0 0 1 1 1 1 1 1)) 325 | '((1 1 1 1 1 1 1 1) 326 | (1 1 1 1 1 1 1 1) 327 | (2 1 1 1 1 1 1 1) 328 | (0 2 1 1 1 1 1 1)) 329 | '((0 2 1 1 1 1 1 1) 330 | (2 1 1 1 1 1 1 1) 331 | (1 1 1 1 1 1 1 1) 332 | (1 1 1 1 1 1 1 1)) 333 | '((0 0 1 1 1 1 1 1)) 334 | '((0 0 2 1 1 1 1 1) 335 | (0 0 0 1 1 1 1 1) 336 | (0 0 0 2 1 1 1 1) 337 | (0 0 0 0 1 1 1 1) 338 | (0 0 0 0 2 1 1 1) 339 | (0 0 0 0 0 2 1 1) 340 | (0 0 0 0 0 0 0 2) 341 | (0 0 0 0 0 0 0 2) 342 | (0 0 0 0 0 2 1 1) 343 | (0 0 0 0 2 1 1 1) 344 | (0 0 0 0 1 1 1 1) 345 | (0 0 0 2 1 1 1 1) 346 | (0 0 0 1 1 1 1 1) 347 | (0 0 2 1 1 1 1 1)))) 348 | 349 | (defmacro pl/butt (dir) 350 | "Generate a butt XPM function for DIR." 351 | (pl/pattern-defun "butt" dir 3 352 | '((0 0 0)) 353 | '((1 1 1) 354 | (0 1 1) 355 | (0 0 1)) 356 | '((0 0 1) 357 | (0 1 1) 358 | (1 1 1)) 359 | nil nil 360 | ;; 2x 361 | '((0 0 0 0 0 0)) 362 | '((1 1 1 1 1 1) 363 | (0 1 1 1 1 1) 364 | (0 0 1 1 1 1) 365 | (0 0 0 1 1 1) 366 | (0 0 0 0 1 1) 367 | (0 0 0 0 0 1)) 368 | '((0 0 0 0 0 1) 369 | (0 0 0 0 1 1) 370 | (0 0 0 1 1 1) 371 | (0 0 1 1 1 1) 372 | (0 1 1 1 1 1) 373 | (1 1 1 1 1 1)))) 374 | 375 | (defmacro pl/chamfer (dir) 376 | "Generate a chamfer XPM function for DIR." 377 | (pl/pattern-defun "chamfer" dir 3 378 | '((0 0 0)) 379 | '((1 1 1) 380 | (0 1 1) 381 | (0 0 1)) 382 | nil nil nil 383 | ;; 2x 384 | '((0 0 0 0 0 0)) 385 | '((1 1 1 1 1 1) 386 | (0 1 1 1 1 1) 387 | (0 0 1 1 1 1) 388 | (0 0 0 1 1 1) 389 | (0 0 0 0 1 1) 390 | (0 0 0 0 0 1)))) 391 | 392 | (defmacro pl/contour (dir) 393 | "Generate a contour XPM function for DIR." 394 | (pl/pattern-defun "contour" dir 10 395 | '((0 0 0 0 0 1 1 1 1 1)) 396 | '((1 1 1 1 1 1 1 1 1 1) 397 | (0 2 1 1 1 1 1 1 1 1) 398 | (0 0 2 1 1 1 1 1 1 1) 399 | (0 0 0 2 1 1 1 1 1 1) 400 | (0 0 0 0 1 1 1 1 1 1) 401 | (0 0 0 0 2 1 1 1 1 1)) 402 | '((0 0 0 0 0 2 1 1 1 1) 403 | (0 0 0 0 0 0 1 1 1 1) 404 | (0 0 0 0 0 0 2 1 1 1) 405 | (0 0 0 0 0 0 0 2 1 1) 406 | (0 0 0 0 0 0 0 0 0 0)) 407 | nil nil 408 | ;; 2x 409 | '((0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 1 1)) 410 | '((1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1) 411 | (1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1) 412 | (0 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1) 413 | (0 0 0 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1) 414 | (0 0 0 0 2 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1) 415 | (0 0 0 0 0 2 1 1 1 1 1 1 1 1 1 1 1 1 1 1) 416 | (0 0 0 0 0 0 2 1 1 1 1 1 1 1 1 1 1 1 1 1) 417 | (0 0 0 0 0 0 0 2 1 1 1 1 1 1 1 1 1 1 1 1) 418 | (0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 1 1 1 1) 419 | (0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 1 1 1 1) 420 | (0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 1 1 1) 421 | (0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 1 1 1)) 422 | '((0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 1) 423 | (0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 1) 424 | (0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1) 425 | (0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1) 426 | (0 0 0 0 0 0 0 0 0 0 0 0 2 1 1 1 1 1 1 1) 427 | (0 0 0 0 0 0 0 0 0 0 0 0 0 2 1 1 1 1 1 1) 428 | (0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1) 429 | (0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 1) 430 | (0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0) 431 | (0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0)))) 432 | 433 | (defmacro pl/curve (dir) 434 | "Generate a curve XPM function for DIR." 435 | (pl/pattern-defun "curve" dir 4 436 | '((0 0 0 0)) 437 | '((1 1 1 1) 438 | (2 1 1 1) 439 | (0 0 1 1) 440 | (0 0 2 1) 441 | (0 0 0 1) 442 | (0 0 0 2)) 443 | '((0 0 0 2) 444 | (0 0 0 1) 445 | (0 0 2 1) 446 | (0 0 1 1) 447 | (2 1 1 1) 448 | (1 1 1 1)) 449 | nil nil 450 | ;; 2x 451 | '((0 0 0 0 0 0 0 0)) 452 | '((1 1 1 1 1 1 1 1) 453 | (1 1 1 1 1 1 1 1) 454 | (1 1 1 1 1 1 1 1) 455 | (0 0 1 1 1 1 1 1) 456 | (0 0 0 2 1 1 1 1) 457 | (0 0 0 0 2 1 1 1) 458 | (0 0 0 0 0 2 1 1) 459 | (0 0 0 0 0 0 1 1) 460 | (0 0 0 0 0 0 1 1) 461 | (0 0 0 0 0 0 0 1) 462 | (0 0 0 0 0 0 0 1) 463 | (0 0 0 0 0 0 0 1)) 464 | '((0 0 0 0 0 0 0 1) 465 | (0 0 0 0 0 0 0 1) 466 | (0 0 0 0 0 0 0 1) 467 | (0 0 0 0 0 0 1 1) 468 | (0 0 0 0 0 0 1 1) 469 | (0 0 0 0 0 2 1 1) 470 | (0 0 0 0 2 1 1 1) 471 | (0 0 0 2 1 1 1 1) 472 | (0 0 1 1 1 1 1 1) 473 | (1 1 1 1 1 1 1 1) 474 | (1 1 1 1 1 1 1 1) 475 | (1 1 1 1 1 1 1 1)))) 476 | 477 | (defmacro pl/rounded (dir) 478 | "Generate a rounded XPM function for DIR." 479 | (pl/pattern-defun "rounded" dir 6 480 | '((0 0 0 0 0 0)) 481 | '((2 1 1 1 1 1) 482 | (0 0 2 1 1 1) 483 | (0 0 0 0 1 1) 484 | (0 0 0 0 2 1) 485 | (0 0 0 0 0 1) 486 | (0 0 0 0 0 2)) 487 | nil nil nil 488 | ;; 2x 489 | '((0 0 0 0 0 0 0 0 0 0 0 0)) 490 | '((1 1 1 1 1 1 1 1 1 1 1 1) 491 | (0 0 2 1 1 1 1 1 1 1 1 1) 492 | (0 0 0 0 1 1 1 1 1 1 1 1) 493 | (0 0 0 0 0 0 1 1 1 1 1 1) 494 | (0 0 0 0 0 0 0 2 1 1 1 1) 495 | (0 0 0 0 0 0 0 0 1 1 1 1) 496 | (0 0 0 0 0 0 0 0 0 1 1 1) 497 | (0 0 0 0 0 0 0 0 0 0 1 1) 498 | (0 0 0 0 0 0 0 0 0 0 1 1) 499 | (0 0 0 0 0 0 0 0 0 0 2 1) 500 | (0 0 0 0 0 0 0 0 0 0 0 1) 501 | (0 0 0 0 0 0 0 0 0 0 0 1)))) 502 | 503 | (defmacro pl/roundstub (dir) 504 | "Generate a roundstub XPM function for DIR." 505 | (pl/pattern-defun "roundstub" dir 3 506 | '((0 0 0)) 507 | '((1 1 1) 508 | (0 0 1) 509 | (0 0 2)) 510 | '((0 0 2) 511 | (0 0 1) 512 | (1 1 1)) 513 | nil nil 514 | ;; 2x 515 | '((0 0 0 0 0 0)) 516 | '((1 1 1 1 1 1) 517 | (2 1 1 1 1 1) 518 | (0 0 0 2 1 1) 519 | (0 0 0 0 1 1) 520 | (0 0 0 0 0 1) 521 | (0 0 0 0 0 1)) 522 | '((0 0 0 0 0 1) 523 | (0 0 0 0 0 1) 524 | (0 0 0 0 1 1) 525 | (0 0 0 2 1 1) 526 | (2 1 1 1 1 1) 527 | (1 1 1 1 1 1)))) 528 | 529 | (defmacro pl/slant (dir) 530 | "Generate a slant XPM function for DIR." 531 | (let* ((row-modifier (if (eq dir 'left) 'identity 'reverse))) 532 | (pl/wrap-defun "slant" dir 'width 533 | '((width (1- (ceiling height 2)))) 534 | `((cl-loop for i from 0 to (1- height) 535 | concat (pl/pattern-to-string (,row-modifier (pl/row-pattern (/ i 2) width))))) 536 | `((cl-loop for i from 0 to (1- (* height 2)) 537 | concat (pl/pattern-to-string (,row-modifier (pl/row-pattern (/ i 2) (* width 2))))))))) 538 | 539 | (defmacro pl/smooth-slant (dir) 540 | "Generate a smoothed slant XPM function for DIR." 541 | (let* ((row-modifier (if (eq dir 'left) 'identity 'reverse))) 542 | (pl/wrap-defun "smooth-slant" dir 'width 543 | '((width (1- (ceiling height 2)))) 544 | `((cl-loop for i from 0 to (1- height) 545 | concat (pl/pattern-to-string 546 | (,row-modifier 547 | (pl/row-pattern (/ i 2) width (cl-mod i 2)))))) 548 | `((cl-loop for i from 0 to (1- (* height 2)) 549 | concat (pl/pattern-to-string 550 | (,row-modifier 551 | (pl/row-pattern (/ i 2) (* width 2) (cl-mod i 2))))))))) 552 | 553 | (defmacro pl/wave (dir) 554 | "Generate a wave XPM function for DIR." 555 | (pl/pattern-defun "wave" dir 11 556 | '((0 0 0 0 0 0 1 1 1 1 1)) 557 | '((2 1 1 1 1 1 1 1 1 1 1) 558 | (0 0 1 1 1 1 1 1 1 1 1) 559 | (0 0 0 1 1 1 1 1 1 1 1) 560 | (0 0 0 2 1 1 1 1 1 1 1) 561 | (0 0 0 0 1 1 1 1 1 1 1) 562 | (0 0 0 0 2 1 1 1 1 1 1) 563 | (0 0 0 0 0 1 1 1 1 1 1) 564 | (0 0 0 0 0 1 1 1 1 1 1) 565 | (0 0 0 0 0 2 1 1 1 1 1)) 566 | '((0 0 0 0 0 0 2 1 1 1 1) 567 | (0 0 0 0 0 0 0 1 1 1 1) 568 | (0 0 0 0 0 0 0 1 1 1 1) 569 | (0 0 0 0 0 0 0 2 1 1 1) 570 | (0 0 0 0 0 0 0 0 1 1 1) 571 | (0 0 0 0 0 0 0 0 2 1 1) 572 | (0 0 0 0 0 0 0 0 0 0 2)) 573 | nil nil 574 | ;; 2x 575 | '((0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 1 1)) 576 | '((1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1) 577 | (0 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1) 578 | (0 0 0 2 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1) 579 | (0 0 0 0 2 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1) 580 | (0 0 0 0 0 2 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1) 581 | (0 0 0 0 0 0 2 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1) 582 | (0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1) 583 | (0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1) 584 | (0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1) 585 | (0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1) 586 | (0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 1 1 1 1 1) 587 | (0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 1 1 1 1 1) 588 | (0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 1 1 1 1) 589 | (0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 1 1 1 1) 590 | (0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 1 1 1 1) 591 | (0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 1 1 1) 592 | (0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 1 1 1) 593 | (0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 1 1 1)) 594 | '((0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 1) 595 | (0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 1) 596 | (0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 1) 597 | (0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1) 598 | (0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1) 599 | (0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1) 600 | (0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1) 601 | (0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1) 602 | (0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1) 603 | (0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1) 604 | (0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 2 1 1 1 1 1) 605 | (0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 2 1 1 1 1) 606 | (0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1) 607 | (0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0)))) 608 | 609 | (defmacro pl/zigzag (dir) 610 | "Generate a zigzag pattern XPM function for DIR." 611 | (pl/pattern-defun "zigzag" dir 3 612 | '((1 1 1) 613 | (0 1 1) 614 | (0 0 1) 615 | (0 0 0) 616 | (0 0 1) 617 | (0 1 1)) 618 | nil nil nil nil 619 | ;; 2x 620 | '((1 1 1 1 1 1) 621 | (0 1 1 1 1 1) 622 | (0 0 1 1 1 1) 623 | (0 0 0 1 1 1) 624 | (0 0 0 0 1 1) 625 | (0 0 0 0 0 1) 626 | (0 0 0 0 0 0) 627 | (0 0 0 0 0 1) 628 | (0 0 0 0 1 1) 629 | (0 0 0 1 1 1) 630 | (0 0 1 1 1 1) 631 | (0 1 1 1 1 1)))) 632 | 633 | (defmacro pl/nil (dir) 634 | "Generate a XPM function that returns nil for DIR." 635 | `(defun ,(intern (format "powerline-nil-%s" (symbol-name dir))) 636 | (face1 face2 &optional height) 637 | nil)) 638 | 639 | (defmacro pl/utf-8 (dir) 640 | "Generate function that returns raw utf-8 symbols." 641 | (let ((dir-name (symbol-name dir)) 642 | (src-face (if (eq dir 'left) 'face1 'face2)) 643 | (dst-face (if (eq dir 'left) 'face2 'face1))) 644 | `(defun ,(intern (format "powerline-utf-8-%s" dir-name)) 645 | (face1 face2 &optional height) 646 | (powerline-raw 647 | (char-to-string ,(intern (format "powerline-utf-8-separator-%s" 648 | dir-name))) 649 | (list :foreground (pl/background-color ,src-face) 650 | :background (pl/background-color ,dst-face) 651 | :inverse-video nil))))) 652 | 653 | 654 | (provide 'powerline-separators) 655 | 656 | ;;; powerline-separators.el ends here 657 | -------------------------------------------------------------------------------- /powerline-themes.el: -------------------------------------------------------------------------------- 1 | ;;; powerline-themes.el --- Themes for Powerline 2 | 3 | ;; Copyright (C) 2012-2013 Donald Ephraim Curtis 4 | ;; Copyright (C) 2013 Jason Milkins 5 | ;; Copyright (C) 2012 Nicolas Rougier 6 | 7 | ;; This file is free software; you can redistribute it and/or modify 8 | ;; it under the terms of the GNU General Public License as published by 9 | ;; the Free Software Foundation; either version 3, or (at your option) 10 | ;; any later version. 11 | 12 | ;; This file is distributed in the hope that it will be useful, 13 | ;; but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | ;; GNU General Public License for more details. 16 | 17 | ;; You should have received a copy of the GNU General Public License 18 | ;; along with this program. If not, see . 19 | 20 | ;;; Commentary: 21 | ;; 22 | ;; Themes for Powerline. 23 | ;; Included themes: default, center, center-evil, vim, and nano. 24 | ;; 25 | 26 | ;;; Code: 27 | 28 | (defcustom powerline-display-buffer-size t 29 | "When non-nil, display the buffer size." 30 | :group 'powerline 31 | :type 'boolean) 32 | 33 | (defcustom powerline-display-mule-info t 34 | "When non-nil, display the mule info." 35 | :group 'powerline 36 | :type 'boolean) 37 | 38 | (defcustom powerline-display-hud t 39 | "When non-nil, display the hud." 40 | :group 'powerline 41 | :type 'boolean) 42 | 43 | ;;;###autoload 44 | (defun powerline-default-theme () 45 | "Setup the default mode-line." 46 | (interactive) 47 | (setq-default mode-line-format 48 | '("%e" 49 | (:eval 50 | (let* ((active (powerline-selected-window-active)) 51 | (mode-line-buffer-id (if active 'mode-line-buffer-id 'mode-line-buffer-id-inactive)) 52 | (mode-line (if active 'mode-line 'mode-line-inactive)) 53 | (face0 (if active 'powerline-active0 'powerline-inactive0)) 54 | (face1 (if active 'powerline-active1 'powerline-inactive1)) 55 | (face2 (if active 'powerline-active2 'powerline-inactive2)) 56 | (separator-left (intern (format "powerline-%s-%s" 57 | (powerline-current-separator) 58 | (car powerline-default-separator-dir)))) 59 | (separator-right (intern (format "powerline-%s-%s" 60 | (powerline-current-separator) 61 | (cdr powerline-default-separator-dir)))) 62 | (lhs (list (powerline-raw "%*" face0 'l) 63 | (when powerline-display-buffer-size 64 | (powerline-buffer-size face0 'l)) 65 | (when powerline-display-mule-info 66 | (powerline-raw mode-line-mule-info face0 'l)) 67 | (powerline-buffer-id `(mode-line-buffer-id ,face0) 'l) 68 | (when (and (boundp 'which-func-mode) which-func-mode) 69 | (powerline-raw which-func-format face0 'l)) 70 | (powerline-raw " " face0) 71 | (funcall separator-left face0 face1) 72 | (when (and (boundp 'erc-track-minor-mode) erc-track-minor-mode) 73 | (powerline-raw erc-modified-channels-object face1 'l)) 74 | (powerline-major-mode face1 'l) 75 | (powerline-process face1) 76 | (powerline-minor-modes face1 'l) 77 | (powerline-narrow face1 'l) 78 | (powerline-raw " " face1) 79 | (funcall separator-left face1 face2) 80 | (powerline-vc face2 'r) 81 | (when (bound-and-true-p nyan-mode) 82 | (powerline-raw (list (nyan-create)) face2 'l)))) 83 | (rhs (list (powerline-raw global-mode-string face2 'r) 84 | (funcall separator-right face2 face1) 85 | (unless window-system 86 | (powerline-raw (char-to-string #xe0a1) face1 'l)) 87 | (powerline-raw "%4l" face1 'l) 88 | (powerline-raw ":" face1 'l) 89 | (powerline-raw "%3c" face1 'r) 90 | (funcall separator-right face1 face0) 91 | (powerline-raw " " face0) 92 | (powerline-raw "%6p" face0 'r) 93 | (when powerline-display-hud 94 | (powerline-hud face0 face2)) 95 | (powerline-fill face0 0) 96 | ))) 97 | (concat (powerline-render lhs) 98 | (powerline-fill face2 (powerline-width rhs)) 99 | (powerline-render rhs))))))) 100 | 101 | ;;;###autoload 102 | (defun powerline-center-theme () 103 | "Setup a mode-line with major and minor modes centered." 104 | (interactive) 105 | (setq-default mode-line-format 106 | '("%e" 107 | (:eval 108 | (let* ((active (powerline-selected-window-active)) 109 | (mode-line-buffer-id (if active 'mode-line-buffer-id 'mode-line-buffer-id-inactive)) 110 | (mode-line (if active 'mode-line 'mode-line-inactive)) 111 | (face0 (if active 'powerline-active0 'powerline-inactive0)) 112 | (face1 (if active 'powerline-active1 'powerline-inactive1)) 113 | (face2 (if active 'powerline-active2 'powerline-inactive2)) 114 | (separator-left (intern (format "powerline-%s-%s" 115 | (powerline-current-separator) 116 | (car powerline-default-separator-dir)))) 117 | (separator-right (intern (format "powerline-%s-%s" 118 | (powerline-current-separator) 119 | (cdr powerline-default-separator-dir)))) 120 | (lhs (list (powerline-raw "%*" face0 'l) 121 | (when powerline-display-buffer-size 122 | (powerline-buffer-size face0 'l)) 123 | (powerline-buffer-id `(mode-line-buffer-id ,face0) 'l) 124 | (powerline-raw " " face0) 125 | (funcall separator-left face0 face1) 126 | (powerline-narrow face1 'l) 127 | (powerline-vc face1))) 128 | (rhs (list (powerline-raw global-mode-string face1 'r) 129 | (powerline-raw "%4l" face1 'r) 130 | (powerline-raw ":" face1) 131 | (powerline-raw "%3c" face1 'r) 132 | (funcall separator-right face1 face0) 133 | (powerline-raw " " face0) 134 | (powerline-raw "%6p" face0 'r) 135 | (when powerline-display-hud 136 | (powerline-hud face2 face1)) 137 | (powerline-fill face0 0))) 138 | (center (list (powerline-raw " " face1) 139 | (funcall separator-left face1 face2) 140 | (when (and (boundp 'erc-track-minor-mode) erc-track-minor-mode) 141 | (powerline-raw erc-modified-channels-object face2 'l)) 142 | (powerline-major-mode face2 'l) 143 | (powerline-process face2) 144 | (powerline-raw " :" face2) 145 | (powerline-minor-modes face2 'l) 146 | (powerline-raw " " face2) 147 | (funcall separator-right face2 face1)))) 148 | (concat (powerline-render lhs) 149 | (powerline-fill-center face1 (/ (powerline-width center) 2.0)) 150 | (powerline-render center) 151 | (powerline-fill face1 (powerline-width rhs)) 152 | (powerline-render rhs))))))) 153 | 154 | (defun powerline-center-evil-theme () 155 | "Setup a mode-line with major, evil, and minor modes centered." 156 | (interactive) 157 | (setq-default mode-line-format 158 | '("%e" 159 | (:eval 160 | (let* ((active (powerline-selected-window-active)) 161 | (mode-line-buffer-id (if active 'mode-line-buffer-id 'mode-line-buffer-id-inactive)) 162 | (mode-line (if active 'mode-line 'mode-line-inactive)) 163 | (face0 (if active 'powerline-active0 'powerline-inactive0)) 164 | (face1 (if active 'powerline-active1 'powerline-inactive1)) 165 | (face2 (if active 'powerline-active2 'powerline-inactive2)) 166 | (separator-left (intern (format "powerline-%s-%s" 167 | (powerline-current-separator) 168 | (car powerline-default-separator-dir)))) 169 | (separator-right (intern (format "powerline-%s-%s" 170 | (powerline-current-separator) 171 | (cdr powerline-default-separator-dir)))) 172 | (lhs (list (powerline-raw "%*" face0 'l) 173 | (when powerline-display-buffer-size 174 | (powerline-buffer-size face0 'l)) 175 | (powerline-buffer-id `(mode-line-buffer-id ,face0) 'l) 176 | (powerline-raw " " face0) 177 | (funcall separator-left face0 face1) 178 | (powerline-narrow face1 'l) 179 | (powerline-vc face1))) 180 | (rhs (list (powerline-raw global-mode-string face1 'r) 181 | (powerline-raw "%4l" face1 'r) 182 | (powerline-raw ":" face1) 183 | (powerline-raw "%3c" face1 'r) 184 | (funcall separator-right face1 face0) 185 | (powerline-raw " " face0) 186 | (powerline-raw "%6p" face0 'r) 187 | (when powerline-display-hud 188 | (powerline-hud face2 face1)))) 189 | (center (append (list (powerline-raw " " face1) 190 | (funcall separator-left face1 face2) 191 | (when (and (boundp 'erc-track-minor-mode) erc-track-minor-mode) 192 | (powerline-raw erc-modified-channels-object face2 'l)) 193 | (powerline-major-mode face2 'l) 194 | (powerline-process face2) 195 | (powerline-raw " " face2)) 196 | (if (split-string (format-mode-line minor-mode-alist)) 197 | (append (if evil-mode 198 | (list (funcall separator-right face2 face1) 199 | (powerline-raw evil-mode-line-tag face1 'l) 200 | (powerline-raw " " face1) 201 | (funcall separator-left face1 face2))) 202 | (list (powerline-minor-modes face2 'l) 203 | (powerline-raw " " face2) 204 | (funcall separator-right face2 face1))) 205 | (list (powerline-raw evil-mode-line-tag face2) 206 | (funcall separator-right face2 face1)))))) 207 | (concat (powerline-render lhs) 208 | (powerline-fill-center face1 (/ (powerline-width center) 2.0)) 209 | (powerline-render center) 210 | (powerline-fill face1 (powerline-width rhs)) 211 | (powerline-render rhs))))))) 212 | 213 | ;;;###autoload 214 | (defun powerline-vim-theme () 215 | "Setup a Vim-like mode-line." 216 | (interactive) 217 | (setq-default mode-line-format 218 | '("%e" 219 | (:eval 220 | (let* ((active (powerline-selected-window-active)) 221 | (mode-line (if active 'mode-line 'mode-line-inactive)) 222 | (face0 (if active 'powerline-active0 'powerline-inactive0)) 223 | (face1 (if active 'powerline-active1 'powerline-inactive1)) 224 | (face2 (if active 'powerline-active2 'powerline-inactive2)) 225 | (separator-left (intern (format "powerline-%s-%s" 226 | (powerline-current-separator) 227 | (car powerline-default-separator-dir)))) 228 | (separator-right (intern (format "powerline-%s-%s" 229 | (powerline-current-separator) 230 | (cdr powerline-default-separator-dir)))) 231 | (lhs (list (powerline-buffer-id `(mode-line-buffer-id ,face0) 'l) 232 | (powerline-raw "[" face0 'l) 233 | (powerline-major-mode face0) 234 | (powerline-process face0) 235 | (powerline-raw "]" face0) 236 | (when (buffer-modified-p) 237 | (powerline-raw "[+]" face0)) 238 | (when buffer-read-only 239 | (powerline-raw "[RO]" face0)) 240 | (powerline-raw "[%z]" face0) 241 | ;; (powerline-raw (concat "[" (mode-line-eol-desc) "]") face0) 242 | (when (and (boundp 'which-func-mode) which-func-mode) 243 | (powerline-raw which-func-format nil 'l)) 244 | (when (and (boundp 'erc-track-minor-mode) erc-track-minor-mode) 245 | (powerline-raw erc-modified-channels-object face1 'l)) 246 | (powerline-raw "[" face0 'l) 247 | (powerline-minor-modes face0) 248 | (powerline-raw "%n" face0) 249 | (powerline-raw "]" face0) 250 | (when (and vc-mode buffer-file-name) 251 | (let ((backend (vc-backend buffer-file-name))) 252 | (when backend 253 | (concat (powerline-raw "[" face0 'l) 254 | (powerline-raw (format "%s / %s" backend (vc-working-revision buffer-file-name backend)) face0) 255 | (powerline-raw "]" face0))))))) 256 | (rhs (list (powerline-raw '(10 "%i") face0) 257 | (powerline-raw global-mode-string face0 'r) 258 | (powerline-raw "%l," face0 'l) 259 | (powerline-raw (format-mode-line '(10 "%c")) face0) 260 | (powerline-raw (replace-regexp-in-string "%" "%%" (format-mode-line '(-3 "%p"))) face0 'r) 261 | (powerline-fill face0 0)))) 262 | (concat (powerline-render lhs) 263 | (powerline-fill face0 (powerline-width rhs)) 264 | (powerline-render rhs))))))) 265 | 266 | ;;;###autoload 267 | (defun powerline-nano-theme () 268 | "Setup a nano-like mode-line." 269 | (interactive) 270 | (setq-default mode-line-format 271 | '("%e" 272 | (:eval 273 | (let* ((active (powerline-selected-window-active)) 274 | (face0 (if active 'powerline-active0 'powerline-inactive0)) 275 | (lhs (list (powerline-raw (concat "GNU Emacs " 276 | (number-to-string 277 | emacs-major-version) 278 | "." 279 | (number-to-string 280 | emacs-minor-version)) 281 | face0 'l))) 282 | (rhs (list (if (buffer-modified-p) (powerline-raw "Modified" face0 'r)) 283 | (powerline-fill face0 0))) 284 | (center (list (powerline-raw "%b" face0)))) 285 | (concat (powerline-render lhs) 286 | (powerline-fill-center face0 (/ (powerline-width center) 2.0)) 287 | (powerline-render center) 288 | (powerline-fill face0 (powerline-width rhs)) 289 | (powerline-render rhs))))))) 290 | 291 | 292 | (provide 'powerline-themes) 293 | 294 | ;;; powerline-themes.el ends here 295 | -------------------------------------------------------------------------------- /powerline.el: -------------------------------------------------------------------------------- 1 | ;;; powerline.el --- Rewrite of Powerline 2 | 3 | ;; Copyright (C) 2012-2013 Donald Ephraim Curtis 4 | ;; Copyright (C) 2013 Jason Milkins 5 | ;; Copyright (C) 2012 Nicolas Rougier 6 | 7 | ;; Author: Donald Ephraim Curtis 8 | ;; URL: http://github.com/milkypostman/powerline/ 9 | ;; Version: 2.5 10 | ;; Keywords: mode-line 11 | ;; Package-Requires: ((cl-lib "0.2")) 12 | 13 | ;; This file is free software; you can redistribute it and/or modify 14 | ;; it under the terms of the GNU General Public License as published by 15 | ;; the Free Software Foundation; either version 3, or (at your option) 16 | ;; any later version. 17 | 18 | ;; This file is distributed in the hope that it will be useful, 19 | ;; but WITHOUT ANY WARRANTY; without even the implied warranty of 20 | ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 21 | ;; GNU General Public License for more details. 22 | 23 | ;; You should have received a copy of the GNU General Public License 24 | ;; along with this program. If not, see . 25 | 26 | ;;; Commentary: 27 | ;; 28 | ;; Powerline is a library for customizing the mode-line that is based on the Vim 29 | ;; Powerline. A collection of predefined themes comes with the package. 30 | ;; 31 | 32 | ;;; Code: 33 | 34 | (eval-and-compile (require 'powerline-themes)) 35 | (eval-and-compile (require 'powerline-separators)) 36 | 37 | (require 'cl-lib) 38 | 39 | (defgroup powerline nil 40 | "Powerline, a prettier mode line." 41 | :group 'mode-line) 42 | 43 | (defface powerline-active0 '((t (:inherit mode-line))) 44 | "Powerline face 0." 45 | :group 'powerline) 46 | 47 | (defface powerline-active1 '((t (:background "grey17" :foreground "white" :inherit mode-line))) 48 | "Powerline face 1." 49 | :group 'powerline) 50 | 51 | (defface powerline-active2 '((t (:background "grey40" :foreground "white" :inherit mode-line))) 52 | "Powerline face 2." 53 | :group 'powerline) 54 | 55 | (defface powerline-inactive0 56 | '((t (:inherit mode-line-inactive))) 57 | "Powerline face 0." 58 | :group 'powerline) 59 | 60 | (defface powerline-inactive1 61 | '((t (:background "grey11" :inherit mode-line-inactive))) 62 | "Powerline face 1." 63 | :group 'powerline) 64 | 65 | (defface powerline-inactive2 66 | '((t (:background "grey20" :inherit mode-line-inactive))) 67 | "Powerline face 2." 68 | :group 'powerline) 69 | 70 | (defface mode-line-buffer-id-inactive 71 | '((t (:inherit mode-line-buffer-id))) 72 | "Powerline mode-line face" 73 | :group 'powerline) 74 | 75 | (defcustom powerline-default-separator 'arrow 76 | "The separator to use for the default theme. 77 | 78 | Valid Values: alternate, arrow, arrow-fade, bar, box, brace, 79 | butt, chamfer, contour, curve, rounded, roundstub, wave, zigzag, 80 | slant, utf-8." 81 | :group 'powerline 82 | :type '(choice (const alternate) 83 | (const arrow) 84 | (const arrow-fade) 85 | (const bar) 86 | (const box) 87 | (const brace) 88 | (const butt) 89 | (const chamfer) 90 | (const contour) 91 | (const curve) 92 | (const rounded) 93 | (const roundstub) 94 | (const slant) 95 | (const smooth-slant) 96 | (const wave) 97 | (const zigzag) 98 | (const utf-8) 99 | (const nil))) 100 | 101 | (defcustom powerline-utf-8-separator-left #xe0b0 102 | "The unicode character number for the left facing separator" 103 | :group 'powerline 104 | :type '(choice integer (const nil))) 105 | 106 | (defcustom powerline-utf-8-separator-right #xe0b2 107 | "The unicode character number for the right facing separator" 108 | :group 'powerline 109 | :type '(choice integer (const nil))) 110 | 111 | (defcustom powerline-default-separator-dir '(left . right) 112 | "The separator direction to use for the default theme. 113 | 114 | CONS of the form (DIR . DIR) denoting the lean of the 115 | separators for the left and right side of the powerline. 116 | 117 | DIR must be one of: left, right" 118 | :group 'powerline 119 | :type '(cons (choice :tag "Left Hand Side" (const left) (const right)) 120 | (choice :tag "Right Hand Side" (const left) (const right)))) 121 | 122 | (defcustom powerline-height nil 123 | "Override the mode-line height." 124 | :group 'powerline 125 | :type '(choice integer (const nil))) 126 | 127 | (defcustom powerline-text-scale-factor nil 128 | "Scale of mode-line font size to default text size. 129 | 130 | Smaller mode-line fonts will be a float value less that 1. 131 | Larger mode-line fonts require a float value greater than 1. 132 | 133 | This is needed to make sure that text is properly aligned." 134 | :group 'powerline 135 | :type '(choice float integer (const nil))) 136 | 137 | (defcustom powerline-buffer-size-suffix t 138 | "Display the buffer size suffix." 139 | :group 'powerline 140 | :type 'boolean) 141 | 142 | (defcustom powerline-gui-use-vcs-glyph nil 143 | "Display a unicode character to represent a version control system. 144 | Not always supported in GUI." 145 | :group 'powerline 146 | :type 'boolean) 147 | 148 | (defcustom powerline-narrowed-indicator "Narrow" 149 | "A string to display in the mode-line when the buffer is narrowed." 150 | :group 'powerline 151 | :type 'string) 152 | 153 | (defun pl/create-or-get-cache () 154 | "Return a frame-local hash table that acts as a memoization cache for powerline. 155 | Create one if the frame doesn't have one yet." 156 | (let ((table (frame-parameter nil 'powerline-cache))) 157 | (if (hash-table-p table) table (pl/reset-cache)))) 158 | 159 | (defun pl/reset-cache () 160 | "Reset and return the frame-local hash table used for a memoization cache." 161 | (let ((table (make-hash-table :test 'equal))) 162 | ;; Store it as a frame-local variable 163 | (modify-frame-parameters nil `((powerline-cache . ,table))) 164 | table)) 165 | 166 | (defun powerline-current-separator () 167 | "Get the current default separator. Always returns utf-8 in non-gui mode." 168 | (if window-system 169 | powerline-default-separator 170 | 'utf-8)) 171 | 172 | ;; 173 | ;; the frame-local powerline cache causes problems if included in a saved desktop, 174 | ;; so delete it before the desktop is saved. 175 | ;; 176 | ;; see https://github.com/milkypostman/powerline/issues/58 177 | ;; 178 | ;; It is better to put the following code into your init file for Emacs 24.4 or later. 179 | ;; (require 'frameset) 180 | ;; (push '(powerline-cache . :never) frameset-filter-alist) 181 | ;; 182 | (defun powerline-delete-cache (&optional frame) 183 | "Set the FRAME cache to nil." 184 | (set-frame-parameter frame 'powerline-cache nil)) 185 | 186 | (defun powerline-desktop-save-delete-cache () 187 | "Set all caches to nil. 188 | This is not done if `frameset-filter-alist' has :never for powerline-cache." 189 | (unless (and (boundp 'frameset-filter-alist) 190 | (eq (cdr (assq 'powerline-cache frameset-filter-alist)) 191 | :never)) 192 | (dolist (fr (frame-list)) (powerline-delete-cache fr)))) 193 | 194 | (add-hook 'desktop-save-hook 'powerline-desktop-save-delete-cache) 195 | 196 | ;; from memoize.el @ http://nullprogram.com/blog/2010/07/26/ 197 | (defun pl/memoize (func) 198 | "Memoize FUNC. 199 | If argument is a symbol then install the memoized function over 200 | the original function. Use frame-local memoization." 201 | (cl-typecase func 202 | (symbol (fset func (pl/memoize-wrap-frame-local (symbol-function func))) func) 203 | (function (pl/memoize-wrap-frame-local func)))) 204 | 205 | (defun pl/memoize-wrap-frame-local (func) 206 | "Return the memoized version of FUNC. 207 | The memoization cache is frame-local." 208 | (let ((funcid (cl-gensym))) 209 | `(lambda (&rest args) 210 | ,(concat (documentation func) (format "\n(memoized function %s)" funcid)) 211 | (let* ((cache (pl/create-or-get-cache)) 212 | (key (cons ',funcid args)) 213 | (val (gethash key cache))) 214 | (if val 215 | val 216 | (puthash key (apply ,func args) cache)))))) 217 | 218 | (defun pl/separator-height () 219 | "Get default height for rendering separators." 220 | (or powerline-height (frame-char-height))) 221 | 222 | (defun powerline-reset () 223 | "Reset memoized functions." 224 | (interactive) 225 | (pl/memoize (pl/alternate left)) 226 | (pl/memoize (pl/alternate right)) 227 | (pl/memoize (pl/arrow left)) 228 | (pl/memoize (pl/arrow right)) 229 | (pl/memoize (pl/arrow-fade left)) 230 | (pl/memoize (pl/arrow-fade right)) 231 | (pl/memoize (pl/bar left)) 232 | (pl/memoize (pl/bar right)) 233 | (pl/memoize (pl/box left)) 234 | (pl/memoize (pl/box right)) 235 | (pl/memoize (pl/brace left)) 236 | (pl/memoize (pl/brace right)) 237 | (pl/memoize (pl/butt left)) 238 | (pl/memoize (pl/butt right)) 239 | (pl/memoize (pl/chamfer left)) 240 | (pl/memoize (pl/chamfer right)) 241 | (pl/memoize (pl/contour left)) 242 | (pl/memoize (pl/contour right)) 243 | (pl/memoize (pl/curve left)) 244 | (pl/memoize (pl/curve right)) 245 | (pl/memoize (pl/rounded left)) 246 | (pl/memoize (pl/rounded right)) 247 | (pl/memoize (pl/roundstub left)) 248 | (pl/memoize (pl/roundstub right)) 249 | (pl/memoize (pl/slant left)) 250 | (pl/memoize (pl/slant right)) 251 | (pl/memoize (pl/smooth-slant left)) 252 | (pl/memoize (pl/smooth-slant right)) 253 | (pl/memoize (pl/wave left)) 254 | (pl/memoize (pl/wave right)) 255 | (pl/memoize (pl/zigzag left)) 256 | (pl/memoize (pl/zigzag right)) 257 | (pl/memoize (pl/nil left)) 258 | (pl/memoize (pl/nil right)) 259 | (pl/utf-8 left) 260 | (pl/utf-8 right) 261 | (pl/reset-cache)) 262 | 263 | (powerline-reset) 264 | 265 | (defun pl/make-xpm (name color1 color2 data) 266 | "Return an XPM image with NAME using COLOR1 and COLOR2 bits specified in DATA. 267 | COLOR1 signifies enabled, and COLOR2 signifies disabled." 268 | (when window-system 269 | (create-image 270 | (concat 271 | (format "/* XPM */ 272 | static char * %s[] = { 273 | \"%i %i 2 1\", 274 | \". c %s\", 275 | \" c %s\", 276 | " 277 | (downcase (replace-regexp-in-string " " "_" name)) 278 | (length (car data)) 279 | (length data) 280 | (or (pl/hex-color color1) "None") 281 | (or (pl/hex-color color2) "None")) 282 | (let ((len (length data)) 283 | (idx 0)) 284 | (apply 'concat 285 | (mapcar #'(lambda (dl) 286 | (setq idx (+ idx 1)) 287 | (concat 288 | "\"" 289 | (concat 290 | (mapcar #'(lambda (d) 291 | (if (eq d 0) 292 | (string-to-char " ") 293 | (string-to-char "."))) 294 | dl)) 295 | (if (eq idx len) 296 | "\"};" 297 | "\",\n"))) 298 | data)))) 299 | 'xpm t :scale 1 :ascent 'center))) 300 | 301 | (defun pl/percent-xpm 302 | (height pmax pmin winend winstart width color1 color2) 303 | "Generate percentage xpm of HEIGHT for PMAX to PMIN given WINEND and WINSTART. 304 | Use WIDTH and COLOR1 and COLOR2." 305 | (let* ((height- (1- height)) 306 | (fillstart (round (* height- (/ (float winstart) (float pmax))))) 307 | (fillend (round (* height- (/ (float winend) (float pmax))))) 308 | (data nil) 309 | (i 0)) 310 | (while (< i height) 311 | (setq data (cons 312 | (if (and (<= fillstart i) 313 | (<= i fillend)) 314 | (append (make-list width 1)) 315 | (append (make-list width 0))) 316 | data)) 317 | (setq i (+ i 1))) 318 | (pl/make-xpm "percent" color1 color2 (reverse data)))) 319 | 320 | (pl/memoize 'pl/percent-xpm) 321 | 322 | ;;;###autoload 323 | (defun powerline-hud (face1 face2 &optional width) 324 | "Return XPM of relative buffer location using FACE1 and FACE2 of optional WIDTH." 325 | (unless width (setq width 2)) 326 | (let ((color1 (if face1 (face-background face1) "None")) 327 | (color2 (if face2 (face-background face2) "None")) 328 | (height (or powerline-height (frame-char-height))) 329 | pmax 330 | pmin 331 | (ws (window-start)) 332 | (we (window-end))) 333 | (save-restriction 334 | (widen) 335 | (setq pmax (point-max)) 336 | (setq pmin (point-min))) 337 | (pl/percent-xpm height pmax pmin we ws 338 | (* (frame-char-width) width) color1 color2))) 339 | 340 | ;;;###autoload 341 | (defun powerline-mouse (click-group click-type string) 342 | "Return mouse handler for CLICK-GROUP given CLICK-TYPE and STRING." 343 | (cond ((eq click-group 'minor) 344 | (cond ((eq click-type 'menu) 345 | `(lambda (event) 346 | (interactive "@e") 347 | (minor-mode-menu-from-indicator ,string))) 348 | ((eq click-type 'help) 349 | `(lambda (event) 350 | (interactive "@e") 351 | (describe-minor-mode-from-indicator ,string))) 352 | (t 353 | `(lambda (event) 354 | (interactive "@e") 355 | nil)))) 356 | (t 357 | `(lambda (event) 358 | (interactive "@e") 359 | nil)))) 360 | 361 | ;;;###autoload 362 | (defun powerline-concat (&rest strings) 363 | "Concatonate STRINGS and pad sides by spaces." 364 | (concat 365 | " " 366 | (mapconcat 'identity (delq nil strings) " ") 367 | " ")) 368 | 369 | ;;;###autoload 370 | (defmacro defpowerline (name body) 371 | "Create function NAME by wrapping BODY with powerline padding an propetization." 372 | `(defun ,name 373 | (&optional face pad) 374 | (powerline-raw ,body face pad))) 375 | 376 | (defun pl/property-substrings (str prop) 377 | "Return a list of substrings of STR when PROP change." 378 | (let ((beg 0) (end 0) 379 | (len (length str)) 380 | (out)) 381 | (while (< end (length str)) 382 | (setq end (or (next-single-property-change beg prop str) len)) 383 | (setq out (append out (list (substring str beg (setq beg end)))))) 384 | out)) 385 | 386 | (defun pl/assure-list (item) 387 | "Assure that ITEM is a list." 388 | (if (listp item) 389 | item 390 | (list item))) 391 | 392 | (defun pl/add-text-property (str prop val) 393 | (mapconcat 394 | (lambda (mm) 395 | (let ((cur (pl/assure-list (get-text-property 0 'face mm)))) 396 | (propertize mm 'face (append cur (list val))))) 397 | (pl/property-substrings str prop) 398 | "")) 399 | 400 | ;;;###autoload 401 | (defun powerline-raw (str &optional face pad) 402 | "Render STR as mode-line data using FACE and optionally PAD import. 403 | PAD can be left (`l') or right (`r')." 404 | (when str 405 | (let* ((rendered-str (format-mode-line str)) 406 | (padded-str (concat 407 | (when (and (> (length rendered-str) 0) (eq pad 'l)) " ") 408 | (if (listp str) rendered-str str) 409 | (when (and (> (length rendered-str) 0) (eq pad 'r)) " ")))) 410 | 411 | (if face 412 | (pl/add-text-property padded-str 'face face) 413 | padded-str)))) 414 | 415 | ;;;###autoload 416 | (defun powerline-fill (face reserve) 417 | "Return empty space using FACE and leaving RESERVE space on the right." 418 | (unless reserve 419 | (setq reserve 20)) 420 | (when powerline-text-scale-factor 421 | (setq reserve (* powerline-text-scale-factor reserve))) 422 | (when (and window-system (eq 'right (get-scroll-bar-mode))) 423 | (setq reserve (- reserve 3))) 424 | (propertize " " 425 | 'display `((space :align-to (- (+ right right-fringe right-margin) ,reserve))) 426 | 'face face)) 427 | 428 | (defun powerline-fill-center (face reserve) 429 | "Return empty space using FACE to center of remaining space. 430 | Leave RESERVE space on the right." 431 | (unless reserve 432 | (setq reserve 20)) 433 | (when powerline-text-scale-factor 434 | (setq reserve (* powerline-text-scale-factor reserve))) 435 | (propertize " " 436 | 'display `((space :align-to (- (+ center (.5 . right-margin)) ,reserve 437 | (.5 . left-margin)))) 438 | 'face face)) 439 | 440 | ;;;###autoload (autoload 'powerline-major-mode "powerline") 441 | (defpowerline powerline-major-mode 442 | (propertize (format-mode-line mode-name) 443 | 'mouse-face 'mode-line-highlight 444 | 'help-echo "Major mode\n\ mouse-1: Display major mode menu\n\ mouse-2: Show help for major mode\n\ mouse-3: Toggle minor modes" 445 | 'local-map (let ((map (make-sparse-keymap))) 446 | (define-key map [mode-line down-mouse-1] 447 | `(menu-item ,(purecopy "Menu Bar") ignore 448 | :filter (lambda (_) (mouse-menu-major-mode-map)))) 449 | (define-key map [mode-line mouse-2] 'describe-mode) 450 | (define-key map [mode-line down-mouse-3] mode-line-mode-menu) 451 | map))) 452 | 453 | ;;;###autoload (autoload 'powerline-minor-modes "powerline") 454 | (defpowerline powerline-minor-modes 455 | (mapconcat (lambda (mm) 456 | (propertize mm 457 | 'mouse-face 'mode-line-highlight 458 | 'help-echo "Minor mode\n mouse-1: Display minor mode menu\n mouse-2: Show help for minor mode\n mouse-3: Toggle minor modes" 459 | 'local-map (let ((map (make-sparse-keymap))) 460 | (define-key map 461 | [mode-line down-mouse-1] 462 | (powerline-mouse 'minor 'menu mm)) 463 | (define-key map 464 | [mode-line mouse-2] 465 | (powerline-mouse 'minor 'help mm)) 466 | (define-key map 467 | [mode-line down-mouse-3] 468 | (powerline-mouse 'minor 'menu mm)) 469 | (define-key map 470 | [header-line down-mouse-3] 471 | (powerline-mouse 'minor 'menu mm)) 472 | map))) 473 | (split-string (format-mode-line minor-mode-alist)) 474 | (propertize " " 'face face))) 475 | 476 | ;;;###autoload (autoload 'powerline-narrow "powerline") 477 | (defpowerline powerline-narrow 478 | (when ;; (buffer-narrowed-p) introduced in Emacs 24.3. 479 | (/= (- (point-max) (point-min)) (buffer-size)) 480 | (propertize powerline-narrowed-indicator 481 | 'mouse-face 'mode-line-highlight 482 | 'help-echo "mouse-1: Remove narrowing from the current buffer" 483 | 'local-map (make-mode-line-mouse-map 484 | 'mouse-1 'mode-line-widen)))) 485 | 486 | ;;;###autoload (autoload 'powerline-vc "powerline") 487 | (defpowerline powerline-vc 488 | (when (and (buffer-file-name (current-buffer)) vc-mode) 489 | (if (and window-system (not powerline-gui-use-vcs-glyph)) 490 | (format-mode-line '(vc-mode vc-mode)) 491 | (format " %s%s" 492 | (char-to-string #xe0a0) 493 | (format-mode-line '(vc-mode vc-mode)))))) 494 | 495 | ;;;###autoload (autoload 'powerline-encoding "powerline") 496 | (defpowerline powerline-encoding 497 | (let ((buf-coding (format "%s" buffer-file-coding-system))) 498 | (if (string-match "\\(dos\\|unix\\|mac\\)" buf-coding) 499 | (match-string 1 buf-coding) 500 | buf-coding))) 501 | 502 | 503 | ;;;###autoload (autoload 'powerline-buffer-size "powerline") 504 | (defpowerline powerline-buffer-size 505 | (propertize 506 | (if powerline-buffer-size-suffix 507 | "%I" 508 | "%i") 509 | 'mouse-face 'mode-line-highlight 510 | 'local-map (make-mode-line-mouse-map 511 | 'mouse-1 (lambda () (interactive) 512 | (setq powerline-buffer-size-suffix 513 | (not powerline-buffer-size-suffix)) 514 | (force-mode-line-update))))) 515 | 516 | ;;;###autoload (autoload 'powerline-buffer-id "powerline") 517 | (defun powerline-buffer-id (&optional face pad) 518 | (powerline-raw 519 | '(" " (:propertize 520 | mode-line-buffer-identification 521 | 'face face 522 | 'mouse-face 'mode-line-highlight 523 | 'help-echo "Buffer name\n\ mouse-1: Previous buffer\n\ mouse-3: Next buffer" 524 | 'local-map (let ((map (make-sparse-keymap))) 525 | (define-key map [mode-line mouse-1] 'mode-line-previous-buffer) 526 | (define-key map [mode-line mouse-3] 'mode-line-next-buffer) 527 | map))) 528 | face pad)) 529 | 530 | ;;;###autoload (autoload 'powerline-process "powerline") 531 | (defpowerline powerline-process 532 | (cond 533 | ((symbolp mode-line-process) (symbol-value mode-line-process)) 534 | ((listp mode-line-process) (format-mode-line mode-line-process)) 535 | (t mode-line-process))) 536 | 537 | (defvar pl/default-mode-line mode-line-format) 538 | 539 | (defvar pl/minibuffer-selected-window-list '()) 540 | 541 | (defun pl/minibuffer-selected-window () 542 | "Return the selected window when entereing the minibuffer." 543 | (when pl/minibuffer-selected-window-list 544 | (car pl/minibuffer-selected-window-list))) 545 | 546 | (defun pl/minibuffer-setup () 547 | "Save the `minibuffer-selected-window' to `pl/minibuffer-selected-window'." 548 | (push (minibuffer-selected-window) pl/minibuffer-selected-window-list)) 549 | 550 | (add-hook 'minibuffer-setup-hook 'pl/minibuffer-setup) 551 | 552 | (defun pl/minibuffer-exit () 553 | "Set `pl/minibuffer-selected-window' to nil." 554 | (pop pl/minibuffer-selected-window-list)) 555 | 556 | (add-hook 'minibuffer-exit-hook 'pl/minibuffer-exit) 557 | 558 | (defvar powerline-selected-window (frame-selected-window) 559 | "Selected window.") 560 | 561 | (defun powerline-set-selected-window () 562 | "Set the variable `powerline-selected-window' appropriately." 563 | (when (not (minibuffer-window-active-p (frame-selected-window))) 564 | (setq powerline-selected-window (frame-selected-window)) 565 | (force-mode-line-update))) 566 | 567 | (defun powerline-unset-selected-window () 568 | "Unset the variable `powerline-selected-window' and update the mode line." 569 | (setq powerline-selected-window nil) 570 | (force-mode-line-update)) 571 | 572 | (add-hook 'window-configuration-change-hook 'powerline-set-selected-window) 573 | 574 | ;; Watch focus changes 575 | (if (boundp 'after-focus-change-function) 576 | (add-function :after after-focus-change-function 577 | (lambda () 578 | (if (frame-focus-state) 579 | (powerline-set-selected-window) 580 | (powerline-unset-selected-window)))) 581 | (with-no-warnings 582 | (add-hook 'focus-in-hook 'powerline-set-selected-window) 583 | (add-hook 'focus-out-hook 'powerline-unset-selected-window))) 584 | 585 | ;; Executes after the window manager requests that the user's events 586 | ;; be directed to a different frame. 587 | (defadvice handle-switch-frame (after powerline-handle-switch-frame activate) 588 | "Call `powerline-set-selected-window'." 589 | (powerline-set-selected-window)) 590 | 591 | (add-hook 'buffer-list-update-hook #'powerline-set-selected-window) 592 | 593 | ;;;###autoload (autoload 'powerline-selected-window-active "powerline") 594 | (defun powerline-selected-window-active () 595 | "Return whether the current window is active." 596 | (eq powerline-selected-window (selected-window))) 597 | 598 | (defun powerline-revert () 599 | "Revert to the default Emacs mode-line." 600 | (interactive) 601 | (setq-default mode-line-format pl/default-mode-line)) 602 | 603 | (defun pl/render (item) 604 | "Render a powerline ITEM." 605 | (cond 606 | ((and (listp item) (eq 'image (car item))) 607 | (propertize " " 'display item 608 | 'face (plist-get (cdr item) :face))) 609 | (item item))) 610 | 611 | (defun powerline-render (values) 612 | "Render a list of powerline VALUES." 613 | (mapconcat 'pl/render values "")) 614 | 615 | (defun powerline-width (values) 616 | "Get the length of VALUES." 617 | (if values 618 | (let ((val (car values))) 619 | (+ (cond 620 | ((stringp val) (string-width (format-mode-line val))) 621 | ((and (listp val) (eq 'image (car val))) 622 | (car (image-size val))) 623 | (t 0)) 624 | (powerline-width (cdr values)))) 625 | 0)) 626 | 627 | 628 | (provide 'powerline) 629 | 630 | ;;; powerline.el ends here 631 | --------------------------------------------------------------------------------