diff options
Diffstat (limited to '.emacs.d/identica-mode-1.1')
-rw-r--r-- | .emacs.d/identica-mode-1.1/.gitignore | 1 | ||||
-rwxr-xr-x | .emacs.d/identica-mode-1.1/COPYING | 339 | ||||
-rw-r--r-- | .emacs.d/identica-mode-1.1/doc/fdl.texi | 451 | ||||
-rw-r--r-- | .emacs.d/identica-mode-1.1/doc/identica-mode.texi | 345 | ||||
-rw-r--r-- | .emacs.d/identica-mode-1.1/identica-mode.el | 1853 |
5 files changed, 2989 insertions, 0 deletions
diff --git a/.emacs.d/identica-mode-1.1/.gitignore b/.emacs.d/identica-mode-1.1/.gitignore new file mode 100644 index 0000000..26db85e --- /dev/null +++ b/.emacs.d/identica-mode-1.1/.gitignore @@ -0,0 +1 @@ +TAGS
\ No newline at end of file diff --git a/.emacs.d/identica-mode-1.1/COPYING b/.emacs.d/identica-mode-1.1/COPYING new file mode 100755 index 0000000..d511905 --- /dev/null +++ b/.emacs.d/identica-mode-1.1/COPYING @@ -0,0 +1,339 @@ + GNU GENERAL PUBLIC LICENSE + Version 2, June 1991 + + Copyright (C) 1989, 1991 Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The licenses for most software are designed to take away your +freedom to share and change it. By contrast, the GNU General Public +License is intended to guarantee your freedom to share and change free +software--to make sure the software is free for all its users. This +General Public License applies to most of the Free Software +Foundation's software and to any other program whose authors commit to +using it. (Some other Free Software Foundation software is covered by +the GNU Lesser General Public License instead.) You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +this service if you wish), that you receive source code or can get it +if you want it, that you can change the software or use pieces of it +in new free programs; and that you know you can do these things. + + To protect your rights, we need to make restrictions that forbid +anyone to deny you these rights or to ask you to surrender the rights. +These restrictions translate to certain responsibilities for you if you +distribute copies of the software, or if you modify it. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must give the recipients all the rights that +you have. You must make sure that they, too, receive or can get the +source code. And you must show them these terms so they know their +rights. + + We protect your rights with two steps: (1) copyright the software, and +(2) offer you this license which gives you legal permission to copy, +distribute and/or modify the software. + + Also, for each author's protection and ours, we want to make certain +that everyone understands that there is no warranty for this free +software. If the software is modified by someone else and passed on, we +want its recipients to know that what they have is not the original, so +that any problems introduced by others will not reflect on the original +authors' reputations. + + Finally, any free program is threatened constantly by software +patents. We wish to avoid the danger that redistributors of a free +program will individually obtain patent licenses, in effect making the +program proprietary. To prevent this, we have made it clear that any +patent must be licensed for everyone's free use or not licensed at all. + + The precise terms and conditions for copying, distribution and +modification follow. + + GNU GENERAL PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. This License applies to any program or other work which contains +a notice placed by the copyright holder saying it may be distributed +under the terms of this General Public License. The "Program", below, +refers to any such program or work, and a "work based on the Program" +means either the Program or any derivative work under copyright law: +that is to say, a work containing the Program or a portion of it, +either verbatim or with modifications and/or translated into another +language. (Hereinafter, translation is included without limitation in +the term "modification".) Each licensee is addressed as "you". + +Activities other than copying, distribution and modification are not +covered by this License; they are outside its scope. The act of +running the Program is not restricted, and the output from the Program +is covered only if its contents constitute a work based on the +Program (independent of having been made by running the Program). +Whether that is true depends on what the Program does. + + 1. You may copy and distribute verbatim copies of the Program's +source code as you receive it, in any medium, provided that you +conspicuously and appropriately publish on each copy an appropriate +copyright notice and disclaimer of warranty; keep intact all the +notices that refer to this License and to the absence of any warranty; +and give any other recipients of the Program a copy of this License +along with the Program. + +You may charge a fee for the physical act of transferring a copy, and +you may at your option offer warranty protection in exchange for a fee. + + 2. You may modify your copy or copies of the Program or any portion +of it, thus forming a work based on the Program, and copy and +distribute such modifications or work under the terms of Section 1 +above, provided that you also meet all of these conditions: + + a) You must cause the modified files to carry prominent notices + stating that you changed the files and the date of any change. + + b) You must cause any work that you distribute or publish, that in + whole or in part contains or is derived from the Program or any + part thereof, to be licensed as a whole at no charge to all third + parties under the terms of this License. + + c) If the modified program normally reads commands interactively + when run, you must cause it, when started running for such + interactive use in the most ordinary way, to print or display an + announcement including an appropriate copyright notice and a + notice that there is no warranty (or else, saying that you provide + a warranty) and that users may redistribute the program under + these conditions, and telling the user how to view a copy of this + License. (Exception: if the Program itself is interactive but + does not normally print such an announcement, your work based on + the Program is not required to print an announcement.) + +These requirements apply to the modified work as a whole. If +identifiable sections of that work are not derived from the Program, +and can be reasonably considered independent and separate works in +themselves, then this License, and its terms, do not apply to those +sections when you distribute them as separate works. But when you +distribute the same sections as part of a whole which is a work based +on the Program, the distribution of the whole must be on the terms of +this License, whose permissions for other licensees extend to the +entire whole, and thus to each and every part regardless of who wrote it. + +Thus, it is not the intent of this section to claim rights or contest +your rights to work written entirely by you; rather, the intent is to +exercise the right to control the distribution of derivative or +collective works based on the Program. + +In addition, mere aggregation of another work not based on the Program +with the Program (or with a work based on the Program) on a volume of +a storage or distribution medium does not bring the other work under +the scope of this License. + + 3. You may copy and distribute the Program (or a work based on it, +under Section 2) in object code or executable form under the terms of +Sections 1 and 2 above provided that you also do one of the following: + + a) Accompany it with the complete corresponding machine-readable + source code, which must be distributed under the terms of Sections + 1 and 2 above on a medium customarily used for software interchange; or, + + b) Accompany it with a written offer, valid for at least three + years, to give any third party, for a charge no more than your + cost of physically performing source distribution, a complete + machine-readable copy of the corresponding source code, to be + distributed under the terms of Sections 1 and 2 above on a medium + customarily used for software interchange; or, + + c) Accompany it with the information you received as to the offer + to distribute corresponding source code. (This alternative is + allowed only for noncommercial distribution and only if you + received the program in object code or executable form with such + an offer, in accord with Subsection b above.) + +The source code for a work means the preferred form of the work for +making modifications to it. For an executable work, complete source +code means all the source code for all modules it contains, plus any +associated interface definition files, plus the scripts used to +control compilation and installation of the executable. However, as a +special exception, the source code distributed need not include +anything that is normally distributed (in either source or binary +form) with the major components (compiler, kernel, and so on) of the +operating system on which the executable runs, unless that component +itself accompanies the executable. + +If distribution of executable or object code is made by offering +access to copy from a designated place, then offering equivalent +access to copy the source code from the same place counts as +distribution of the source code, even though third parties are not +compelled to copy the source along with the object code. + + 4. You may not copy, modify, sublicense, or distribute the Program +except as expressly provided under this License. Any attempt +otherwise to copy, modify, sublicense or distribute the Program is +void, and will automatically terminate your rights under this License. +However, parties who have received copies, or rights, from you under +this License will not have their licenses terminated so long as such +parties remain in full compliance. + + 5. You are not required to accept this License, since you have not +signed it. However, nothing else grants you permission to modify or +distribute the Program or its derivative works. These actions are +prohibited by law if you do not accept this License. Therefore, by +modifying or distributing the Program (or any work based on the +Program), you indicate your acceptance of this License to do so, and +all its terms and conditions for copying, distributing or modifying +the Program or works based on it. + + 6. Each time you redistribute the Program (or any work based on the +Program), the recipient automatically receives a license from the +original licensor to copy, distribute or modify the Program subject to +these terms and conditions. You may not impose any further +restrictions on the recipients' exercise of the rights granted herein. +You are not responsible for enforcing compliance by third parties to +this License. + + 7. If, as a consequence of a court judgment or allegation of patent +infringement or for any other reason (not limited to patent issues), +conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot +distribute so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you +may not distribute the Program at all. For example, if a patent +license would not permit royalty-free redistribution of the Program by +all those who receive copies directly or indirectly through you, then +the only way you could satisfy both it and this License would be to +refrain entirely from distribution of the Program. + +If any portion of this section is held invalid or unenforceable under +any particular circumstance, the balance of the section is intended to +apply and the section as a whole is intended to apply in other +circumstances. + +It is not the purpose of this section to induce you to infringe any +patents or other property right claims or to contest validity of any +such claims; this section has the sole purpose of protecting the +integrity of the free software distribution system, which is +implemented by public license practices. Many people have made +generous contributions to the wide range of software distributed +through that system in reliance on consistent application of that +system; it is up to the author/donor to decide if he or she is willing +to distribute software through any other system and a licensee cannot +impose that choice. + +This section is intended to make thoroughly clear what is believed to +be a consequence of the rest of this License. + + 8. If the distribution and/or use of the Program is restricted in +certain countries either by patents or by copyrighted interfaces, the +original copyright holder who places the Program under this License +may add an explicit geographical distribution limitation excluding +those countries, so that distribution is permitted only in or among +countries not thus excluded. In such case, this License incorporates +the limitation as if written in the body of this License. + + 9. The Free Software Foundation may publish revised and/or new versions +of the General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + +Each version is given a distinguishing version number. If the Program +specifies a version number of this License which applies to it and "any +later version", you have the option of following the terms and conditions +either of that version or of any later version published by the Free +Software Foundation. If the Program does not specify a version number of +this License, you may choose any version ever published by the Free Software +Foundation. + + 10. If you wish to incorporate parts of the Program into other free +programs whose distribution conditions are different, write to the author +to ask for permission. For software which is copyrighted by the Free +Software Foundation, write to the Free Software Foundation; we sometimes +make exceptions for this. Our decision will be guided by the two goals +of preserving the free status of all derivatives of our free software and +of promoting the sharing and reuse of software generally. + + NO WARRANTY + + 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY +FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN +OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES +PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED +OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS +TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE +PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, +REPAIR OR CORRECTION. + + 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR +REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, +INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING +OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED +TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY +YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER +PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE +POSSIBILITY OF SUCH DAMAGES. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +convey the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + <one line to give the program's name and a brief idea of what it does.> + Copyright (C) <year> <name of author> + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along + with this program; if not, write to the Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + +Also add information on how to contact you by electronic and paper mail. + +If the program is interactive, make it output a short notice like this +when it starts in an interactive mode: + + Gnomovision version 69, Copyright (C) year name of author + Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, the commands you use may +be called something other than `show w' and `show c'; they could even be +mouse-clicks or menu items--whatever suits your program. + +You should also get your employer (if you work as a programmer) or your +school, if any, to sign a "copyright disclaimer" for the program, if +necessary. Here is a sample; alter the names: + + Yoyodyne, Inc., hereby disclaims all copyright interest in the program + `Gnomovision' (which makes passes at compilers) written by James Hacker. + + <signature of Ty Coon>, 1 April 1989 + Ty Coon, President of Vice + +This General Public License does not permit incorporating your program into +proprietary programs. If your program is a subroutine library, you may +consider it more useful to permit linking proprietary applications with the +library. If this is what you want to do, use the GNU Lesser General +Public License instead of this License. diff --git a/.emacs.d/identica-mode-1.1/doc/fdl.texi b/.emacs.d/identica-mode-1.1/doc/fdl.texi new file mode 100644 index 0000000..96ce74e --- /dev/null +++ b/.emacs.d/identica-mode-1.1/doc/fdl.texi @@ -0,0 +1,451 @@ +@c The GNU Free Documentation License. +@center Version 1.2, November 2002 + +@c This file is intended to be included within another document, +@c hence no sectioning command or @node. + +@display +Copyright @copyright{} 2000,2001,2002 Free Software Foundation, Inc. +51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA + +Everyone is permitted to copy and distribute verbatim copies +of this license document, but changing it is not allowed. +@end display + +@enumerate 0 +@item +PREAMBLE + +The purpose of this License is to make a manual, textbook, or other +functional and useful document @dfn{free} in the sense of freedom: to +assure everyone the effective freedom to copy and redistribute it, +with or without modifying it, either commercially or noncommercially. +Secondarily, this License preserves for the author and publisher a way +to get credit for their work, while not being considered responsible +for modifications made by others. + +This License is a kind of ``copyleft'', which means that derivative +works of the document must themselves be free in the same sense. It +complements the GNU General Public License, which is a copyleft +license designed for free software. + +We have designed this License in order to use it for manuals for free +software, because free software needs free documentation: a free +program should come with manuals providing the same freedoms that the +software does. But this License is not limited to software manuals; +it can be used for any textual work, regardless of subject matter or +whether it is published as a printed book. We recommend this License +principally for works whose purpose is instruction or reference. + +@item +APPLICABILITY AND DEFINITIONS + +This License applies to any manual or other work, in any medium, that +contains a notice placed by the copyright holder saying it can be +distributed under the terms of this License. Such a notice grants a +world-wide, royalty-free license, unlimited in duration, to use that +work under the conditions stated herein. The ``Document'', below, +refers to any such manual or work. Any member of the public is a +licensee, and is addressed as ``you''. You accept the license if you +copy, modify or distribute the work in a way requiring permission +under copyright law. + +A ``Modified Version'' of the Document means any work containing the +Document or a portion of it, either copied verbatim, or with +modifications and/or translated into another language. + +A ``Secondary Section'' is a named appendix or a front-matter section +of the Document that deals exclusively with the relationship of the +publishers or authors of the Document to the Document's overall +subject (or to related matters) and contains nothing that could fall +directly within that overall subject. (Thus, if the Document is in +part a textbook of mathematics, a Secondary Section may not explain +any mathematics.) The relationship could be a matter of historical +connection with the subject or with related matters, or of legal, +commercial, philosophical, ethical or political position regarding +them. + +The ``Invariant Sections'' are certain Secondary Sections whose titles +are designated, as being those of Invariant Sections, in the notice +that says that the Document is released under this License. If a +section does not fit the above definition of Secondary then it is not +allowed to be designated as Invariant. The Document may contain zero +Invariant Sections. If the Document does not identify any Invariant +Sections then there are none. + +The ``Cover Texts'' are certain short passages of text that are listed, +as Front-Cover Texts or Back-Cover Texts, in the notice that says that +the Document is released under this License. A Front-Cover Text may +be at most 5 words, and a Back-Cover Text may be at most 25 words. + +A ``Transparent'' copy of the Document means a machine-readable copy, +represented in a format whose specification is available to the +general public, that is suitable for revising the document +straightforwardly with generic text editors or (for images composed of +pixels) generic paint programs or (for drawings) some widely available +drawing editor, and that is suitable for input to text formatters or +for automatic translation to a variety of formats suitable for input +to text formatters. A copy made in an otherwise Transparent file +format whose markup, or absence of markup, has been arranged to thwart +or discourage subsequent modification by readers is not Transparent. +An image format is not Transparent if used for any substantial amount +of text. A copy that is not ``Transparent'' is called ``Opaque''. + +Examples of suitable formats for Transparent copies include plain +@sc{ascii} without markup, Texinfo input format, La@TeX{} input +format, @acronym{SGML} or @acronym{XML} using a publicly available +@acronym{DTD}, and standard-conforming simple @acronym{HTML}, +PostScript or @acronym{PDF} designed for human modification. Examples +of transparent image formats include @acronym{PNG}, @acronym{XCF} and +@acronym{JPG}. Opaque formats include proprietary formats that can be +read and edited only by proprietary word processors, @acronym{SGML} or +@acronym{XML} for which the @acronym{DTD} and/or processing tools are +not generally available, and the machine-generated @acronym{HTML}, +PostScript or @acronym{PDF} produced by some word processors for +output purposes only. + +The ``Title Page'' means, for a printed book, the title page itself, +plus such following pages as are needed to hold, legibly, the material +this License requires to appear in the title page. For works in +formats which do not have any title page as such, ``Title Page'' means +the text near the most prominent appearance of the work's title, +preceding the beginning of the body of the text. + +A section ``Entitled XYZ'' means a named subunit of the Document whose +title either is precisely XYZ or contains XYZ in parentheses following +text that translates XYZ in another language. (Here XYZ stands for a +specific section name mentioned below, such as ``Acknowledgements'', +``Dedications'', ``Endorsements'', or ``History''.) To ``Preserve the Title'' +of such a section when you modify the Document means that it remains a +section ``Entitled XYZ'' according to this definition. + +The Document may include Warranty Disclaimers next to the notice which +states that this License applies to the Document. These Warranty +Disclaimers are considered to be included by reference in this +License, but only as regards disclaiming warranties: any other +implication that these Warranty Disclaimers may have is void and has +no effect on the meaning of this License. + +@item +VERBATIM COPYING + +You may copy and distribute the Document in any medium, either +commercially or noncommercially, provided that this License, the +copyright notices, and the license notice saying this License applies +to the Document are reproduced in all copies, and that you add no other +conditions whatsoever to those of this License. You may not use +technical measures to obstruct or control the reading or further +copying of the copies you make or distribute. However, you may accept +compensation in exchange for copies. If you distribute a large enough +number of copies you must also follow the conditions in section 3. + +You may also lend copies, under the same conditions stated above, and +you may publicly display copies. + +@item +COPYING IN QUANTITY + +If you publish printed copies (or copies in media that commonly have +printed covers) of the Document, numbering more than 100, and the +Document's license notice requires Cover Texts, you must enclose the +copies in covers that carry, clearly and legibly, all these Cover +Texts: Front-Cover Texts on the front cover, and Back-Cover Texts on +the back cover. Both covers must also clearly and legibly identify +you as the publisher of these copies. The front cover must present +the full title with all words of the title equally prominent and +visible. You may add other material on the covers in addition. +Copying with changes limited to the covers, as long as they preserve +the title of the Document and satisfy these conditions, can be treated +as verbatim copying in other respects. + +If the required texts for either cover are too voluminous to fit +legibly, you should put the first ones listed (as many as fit +reasonably) on the actual cover, and continue the rest onto adjacent +pages. + +If you publish or distribute Opaque copies of the Document numbering +more than 100, you must either include a machine-readable Transparent +copy along with each Opaque copy, or state in or with each Opaque copy +a computer-network location from which the general network-using +public has access to download using public-standard network protocols +a complete Transparent copy of the Document, free of added material. +If you use the latter option, you must take reasonably prudent steps, +when you begin distribution of Opaque copies in quantity, to ensure +that this Transparent copy will remain thus accessible at the stated +location until at least one year after the last time you distribute an +Opaque copy (directly or through your agents or retailers) of that +edition to the public. + +It is requested, but not required, that you contact the authors of the +Document well before redistributing any large number of copies, to give +them a chance to provide you with an updated version of the Document. + +@item +MODIFICATIONS + +You may copy and distribute a Modified Version of the Document under +the conditions of sections 2 and 3 above, provided that you release +the Modified Version under precisely this License, with the Modified +Version filling the role of the Document, thus licensing distribution +and modification of the Modified Version to whoever possesses a copy +of it. In addition, you must do these things in the Modified Version: + +@enumerate A +@item +Use in the Title Page (and on the covers, if any) a title distinct +from that of the Document, and from those of previous versions +(which should, if there were any, be listed in the History section +of the Document). You may use the same title as a previous version +if the original publisher of that version gives permission. + +@item +List on the Title Page, as authors, one or more persons or entities +responsible for authorship of the modifications in the Modified +Version, together with at least five of the principal authors of the +Document (all of its principal authors, if it has fewer than five), +unless they release you from this requirement. + +@item +State on the Title page the name of the publisher of the +Modified Version, as the publisher. + +@item +Preserve all the copyright notices of the Document. + +@item +Add an appropriate copyright notice for your modifications +adjacent to the other copyright notices. + +@item +Include, immediately after the copyright notices, a license notice +giving the public permission to use the Modified Version under the +terms of this License, in the form shown in the Addendum below. + +@item +Preserve in that license notice the full lists of Invariant Sections +and required Cover Texts given in the Document's license notice. + +@item +Include an unaltered copy of this License. + +@item +Preserve the section Entitled ``History'', Preserve its Title, and add +to it an item stating at least the title, year, new authors, and +publisher of the Modified Version as given on the Title Page. If +there is no section Entitled ``History'' in the Document, create one +stating the title, year, authors, and publisher of the Document as +given on its Title Page, then add an item describing the Modified +Version as stated in the previous sentence. + +@item +Preserve the network location, if any, given in the Document for +public access to a Transparent copy of the Document, and likewise +the network locations given in the Document for previous versions +it was based on. These may be placed in the ``History'' section. +You may omit a network location for a work that was published at +least four years before the Document itself, or if the original +publisher of the version it refers to gives permission. + +@item +For any section Entitled ``Acknowledgements'' or ``Dedications'', Preserve +the Title of the section, and preserve in the section all the +substance and tone of each of the contributor acknowledgements and/or +dedications given therein. + +@item +Preserve all the Invariant Sections of the Document, +unaltered in their text and in their titles. Section numbers +or the equivalent are not considered part of the section titles. + +@item +Delete any section Entitled ``Endorsements''. Such a section +may not be included in the Modified Version. + +@item +Do not retitle any existing section to be Entitled ``Endorsements'' or +to conflict in title with any Invariant Section. + +@item +Preserve any Warranty Disclaimers. +@end enumerate + +If the Modified Version includes new front-matter sections or +appendices that qualify as Secondary Sections and contain no material +copied from the Document, you may at your option designate some or all +of these sections as invariant. To do this, add their titles to the +list of Invariant Sections in the Modified Version's license notice. +These titles must be distinct from any other section titles. + +You may add a section Entitled ``Endorsements'', provided it contains +nothing but endorsements of your Modified Version by various +parties---for example, statements of peer review or that the text has +been approved by an organization as the authoritative definition of a +standard. + +You may add a passage of up to five words as a Front-Cover Text, and a +passage of up to 25 words as a Back-Cover Text, to the end of the list +of Cover Texts in the Modified Version. Only one passage of +Front-Cover Text and one of Back-Cover Text may be added by (or +through arrangements made by) any one entity. If the Document already +includes a cover text for the same cover, previously added by you or +by arrangement made by the same entity you are acting on behalf of, +you may not add another; but you may replace the old one, on explicit +permission from the previous publisher that added the old one. + +The author(s) and publisher(s) of the Document do not by this License +give permission to use their names for publicity for or to assert or +imply endorsement of any Modified Version. + +@item +COMBINING DOCUMENTS + +You may combine the Document with other documents released under this +License, under the terms defined in section 4 above for modified +versions, provided that you include in the combination all of the +Invariant Sections of all of the original documents, unmodified, and +list them all as Invariant Sections of your combined work in its +license notice, and that you preserve all their Warranty Disclaimers. + +The combined work need only contain one copy of this License, and +multiple identical Invariant Sections may be replaced with a single +copy. If there are multiple Invariant Sections with the same name but +different contents, make the title of each such section unique by +adding at the end of it, in parentheses, the name of the original +author or publisher of that section if known, or else a unique number. +Make the same adjustment to the section titles in the list of +Invariant Sections in the license notice of the combined work. + +In the combination, you must combine any sections Entitled ``History'' +in the various original documents, forming one section Entitled +``History''; likewise combine any sections Entitled ``Acknowledgements'', +and any sections Entitled ``Dedications''. You must delete all +sections Entitled ``Endorsements.'' + +@item +COLLECTIONS OF DOCUMENTS + +You may make a collection consisting of the Document and other documents +released under this License, and replace the individual copies of this +License in the various documents with a single copy that is included in +the collection, provided that you follow the rules of this License for +verbatim copying of each of the documents in all other respects. + +You may extract a single document from such a collection, and distribute +it individually under this License, provided you insert a copy of this +License into the extracted document, and follow this License in all +other respects regarding verbatim copying of that document. + +@item +AGGREGATION WITH INDEPENDENT WORKS + +A compilation of the Document or its derivatives with other separate +and independent documents or works, in or on a volume of a storage or +distribution medium, is called an ``aggregate'' if the copyright +resulting from the compilation is not used to limit the legal rights +of the compilation's users beyond what the individual works permit. +When the Document is included in an aggregate, this License does not +apply to the other works in the aggregate which are not themselves +derivative works of the Document. + +If the Cover Text requirement of section 3 is applicable to these +copies of the Document, then if the Document is less than one half of +the entire aggregate, the Document's Cover Texts may be placed on +covers that bracket the Document within the aggregate, or the +electronic equivalent of covers if the Document is in electronic form. +Otherwise they must appear on printed covers that bracket the whole +aggregate. + +@item +TRANSLATION + +Translation is considered a kind of modification, so you may +distribute translations of the Document under the terms of section 4. +Replacing Invariant Sections with translations requires special +permission from their copyright holders, but you may include +translations of some or all Invariant Sections in addition to the +original versions of these Invariant Sections. You may include a +translation of this License, and all the license notices in the +Document, and any Warranty Disclaimers, provided that you also include +the original English version of this License and the original versions +of those notices and disclaimers. In case of a disagreement between +the translation and the original version of this License or a notice +or disclaimer, the original version will prevail. + +If a section in the Document is Entitled ``Acknowledgements'', +``Dedications'', or ``History'', the requirement (section 4) to Preserve +its Title (section 1) will typically require changing the actual +title. + +@item +TERMINATION + +You may not copy, modify, sublicense, or distribute the Document except +as expressly provided for under this License. Any other attempt to +copy, modify, sublicense or distribute the Document is void, and will +automatically terminate your rights under this License. However, +parties who have received copies, or rights, from you under this +License will not have their licenses terminated so long as such +parties remain in full compliance. + +@item +FUTURE REVISIONS OF THIS LICENSE + +The Free Software Foundation may publish new, revised versions +of the GNU Free Documentation License from time to time. Such new +versions will be similar in spirit to the present version, but may +differ in detail to address new problems or concerns. See +@uref{http://www.gnu.org/copyleft/}. + +Each version of the License is given a distinguishing version number. +If the Document specifies that a particular numbered version of this +License ``or any later version'' applies to it, you have the option of +following the terms and conditions either of that specified version or +of any later version that has been published (not as a draft) by the +Free Software Foundation. If the Document does not specify a version +number of this License, you may choose any version ever published (not +as a draft) by the Free Software Foundation. +@end enumerate + +@page +@heading ADDENDUM: How to use this License for your documents + +To use this License in a document you have written, include a copy of +the License in the document and put the following copyright and +license notices just after the title page: + +@smallexample +@group + Copyright (C) @var{year} @var{your name}. + Permission is granted to copy, distribute and/or modify this document + under the terms of the GNU Free Documentation License, Version 1.2 + or any later version published by the Free Software Foundation; + with no Invariant Sections, no Front-Cover Texts, and no Back-Cover + Texts. A copy of the license is included in the section entitled ``GNU + Free Documentation License''. +@end group +@end smallexample + +If you have Invariant Sections, Front-Cover Texts and Back-Cover Texts, +replace the ``with@dots{}Texts.'' line with this: + +@smallexample +@group + with the Invariant Sections being @var{list their titles}, with + the Front-Cover Texts being @var{list}, and with the Back-Cover Texts + being @var{list}. +@end group +@end smallexample + +If you have Invariant Sections without Cover Texts, or some other +combination of the three, merge those two alternatives to suit the +situation. + +If your document contains nontrivial examples of program code, we +recommend releasing these examples in parallel under your choice of +free software license, such as the GNU General Public License, +to permit their use in free software. + +@c Local Variables: +@c ispell-local-pdict: "ispell-dict" +@c End: + diff --git a/.emacs.d/identica-mode-1.1/doc/identica-mode.texi b/.emacs.d/identica-mode-1.1/doc/identica-mode.texi new file mode 100644 index 0000000..a620dd5 --- /dev/null +++ b/.emacs.d/identica-mode-1.1/doc/identica-mode.texi @@ -0,0 +1,345 @@ +\input texinfo @c -*-texinfo-*- + +@c %**start of header +@setfilename identica-mode.info +@settitle Identica mode manual +@c %**end of header + +@copying + Copyright @copyright{} 2009 Chris Bryant (@email{chrisbryant@@ucla.edu}). + Permission is granted to copy, distribute and/or modify this document + under the terms of the GNU Free Documentation License, Version 1.2 + or any later version published by the Free Software Foundation; + with no Invariant Sections, no Front-Cover Texts, and no Back-Cover + Texts. A copy of the license is included in the section entitled "GNU + Free Documentation License". +@end copying + +@dircategory Emacs +@direntry +* Identica mode: (identica-mode). Emacs mode for microblogging services. +@end direntry + +@titlepage + @title Identica mode manual + @subtitle v0.3 for identica-mode.el v0.9 + @author Chris Bryant (@email{chrisbryant@@ucla.edu}) + @page + @vskip 0pt plus 1filll + @insertcopying +@end titlepage + +@contents + +@node Top, About Identica mode and obtaining it, (dir), (dir) +@ifnottex +@top identica-mode +This manual is for identica-mode.el, version 0.9. +@end ifnottex + +@menu +* About Identica mode and obtaining it:: +* Installation and configuration:: +* Using identica-mode.el:: +* Credits and contributing:: +* GNU Free Documentation License:: +@end menu + +@node About Identica mode and obtaining it, Installation and configuration, Top, Top +@chapter About Identica mode and obtaining it + +@menu +* About identica-mode.el and this manual:: +* Getting a copy:: +@end menu + +@node About identica-mode.el and this manual, Getting a copy, About Identica mode and obtaining it, About Identica mode and obtaining it +@section About identica-mode.el and this manual + +@firstparagraphindent none +This manual instructs in the use of identica-mode.el, a major mode for GNU Emacs used to perform useful actions with @uref{http://status.net, StatusNet} microblogging services, like @uref{http://identi.ca, identi.ca}. + +@paragraphindent 3 +identica-mode.el was developed by @uref{mailto:gsaldana@@gmail.com, Gabriel Saldana} and other contributors (@ref{Credits}). It is originally based on Twittering mode version 0.6 by Y. Hayamizu and Tsuyoshi CHO. + +@node Getting a copy, , About identica-mode.el and this manual, About Identica mode and obtaining it +@section Getting a copy + +@firstparagraphindent none +Identica mode can be obtained from the @uref{https://savannah.gnu.org, Savannah} software forge. The URLs for the Identica mode project are: + +@itemize @bullet +@item @uref{http://www.nongnu.org/identica-mode/, http://www.nongnu.org/identica-mode} - Main website +@item @uref{https://savannah.nongnu.org/projects/identica-mode/, https://savannah.nongnu.org/projects/identica-mode} - Software forge +@end itemize + +@paragraphindent 3 +You can obtain identica-mode.el directly from the git repository at Savannah by executing a git clone command: +@* +@example +git clone git://git.savannah.nongnu.org/identica-mode.git +@end example +@* +@paragraphindent 3 +This action will fetch the latest identica-mode.el file as well as the latest manual, located under the @code{doc/} directory. + +@node Installation and configuration, Using identica-mode.el, About Identica mode and obtaining it, Top +@chapter Installation and configuration + +@menu +* Installing identica-mode.el:: +* Configuring GNU Emacs:: +@end menu + +@node Installing identica-mode.el, Configuring GNU Emacs, Installation and configuration, Installation and configuration +@section Installing identica-mode.el + +@firstparagraphindent none +Installation of indentica-mode.el is fairly straightforward. Like most GNU Emacs customizations, it is recommended you place your identica-mode.el file under your @code{emacs.d} directory. The location of this directory will vary between OSs, but it is generally under @code{~/.emacs.d/} for UNIX style systems. Consult your @uref{http://www.gnu.org/software/emacs/, GNU Emacs} documentation. + +@paragraphindent 3 +Alternatively, you can create your own directory for this GNU Emacs mode file, and others, if you choose. Read on for information on how to configure your @code{.emacs} file to find indentica-mode.el. + +@node Configuring GNU Emacs, , Installing identica-mode.el, Installation and configuration +@section Configuring GNU Emacs + +@menu +* identica-mode requirements:: +* Configuring .emacs:: +@end menu + +@node identica-mode requirements, Configuring .emacs, Configuring GNU Emacs, Configuring GNU Emacs +@subsection identica-mode requirements + +@firstparagraphindent none +The following GNU Emacs libraries are required by identica-mode.el. A standard GNU Emacs installation should provide these, but if yours does not, fetch a copy of the @uref{http://www.gnu.org/software/emacs/, GNU Emacs} source. The libraries are generally found under the @code{emacs-<version>/lisp/} directory. + +@itemize @bullet +@item cl +@item xml +@item parse-time +@item longlines +@end itemize + + +@paragraphindent 3 +In addition to the library requirements, the following software is currently required: + +@itemize @bullet +@item GNU Emacs 22 or later +@item Curl +@item Wget +@item UNIX-like OS (GNU/Linux, BSD, etcetera) +@end itemize + +@node Configuring .emacs, , identica-mode requirements, Configuring GNU Emacs +@subsection Configuring .emacs + +@firstparagraphindent none +Some or all or the following settings can be configured from within GNU Emacs or written to your @code{.emacs} file. To configure within GNU Emacs, execute @command{M-x} and type @command{customize-group}. When prompted for the group to customize, enter @command{identica-mode}. The settings are: + +@itemize @bullet +@item Identica Idle Time +@item Identica Timer Interval +@item Identica Username +@item Identica Password +@item Laconica Server +@item Identica Default Timeline +@item Identica Display Success Messages +@item Identica Update Status Edit Confirm Cancellation +@item Identica Update Status Method +@item Identica Http Get Timeout +@item Identica Status Format +@end itemize + +@paragraphindent 3 +For general usage, the defaults for each of these settings (excluding Username and Password) should be fine to get started for use with identi.ca. If you wish to customize these settings, please see the @uref{http://status.net/wiki/, StatusNet wiki} for documentation of usage. Management of the customizations can also be performed from within your @code{.emacs} file. Below is a sample, explicitly calling the identica-mode.el file and with an added global keybinding to allow posting from the minibuffer without having the identica buffer active: +@* +@example +;; Identica Mode +(load "/home/identicauser/.emacs.d/identica-mode.el") +(require 'identica-mode) +(setq identica-username "identicauser") +(setq identica-password "password") +(global-set-key "\C-cip" 'identica-update-status-interactive) +@end example +@* +@node Using identica-mode.el, Credits and contributing, Installation and configuration, Top +@chapter Using identica-mode.el + +@menu +* Basic usage:: +* Tips and tricks:: +@end menu + +@node Basic usage, Tips and tricks, Using identica-mode.el, Using identica-mode.el +@section Basic usage + +@menu +* Introduction:: +* Startup:: +* Icons:: +* Replies timeline:: +* Public timeline:: +* Personal timeline:: +* Update status:: +* Send notice:: +* Shorten url:: +@end menu + +@node Introduction, Startup, Basic usage, Basic usage +@subsection Introduction + +@firstparagraphindent none +Identica mode currently works under GNU Emacs in both terminal and graphical mode. Where there are special considerations for one or the other mode, they will be clearly highlighted. The purpose of Identica mode is to provide an easy method to send and view updates while working within a GNU Emacs environment. Thus, the command set detailed below is simple. If you are interested in more complex functionality, feel free to send suggestions through the Savannah project website. Additionally, keep up-to-date with the latest releases. Also, see @ref{Extending identica-mode} for tips on writing your own functions. + +@node Startup, Icons, Introduction, Basic usage +@subsection Startup + +@firstparagraphindent none +To get started using Identica mode, execute @code{M-x} and type @command{identica-mode}. This will initiate the identica-mode buffer, *identica*, and display the default timeline. At any time you wish to refresh the timeline, press the @command{G} key. + +@node Icons, Replies timeline, Startup, Basic usage +@subsection Icons + +@firstparagraphindent none +If you are using GNU Emacs with a graphical interface, you can toggle the view of user icons by pressing the @command{I} key. + +@node Replies timeline, Public timeline, Icons, Basic usage +@subsection Replies timeline + +@firstparagraphindent none +To view your Replies timeline execute: +@* +@example +C-c C-r +@end example + +@node Public timeline, Personal timeline, Replies timeline, Basic usage +@subsection Public timeline + +@firstparagraphindent none +To view the Public timeline execute: +@* +@example +C-c C-g +@end example + +@node Personal timeline, Update status, Public timeline, Basic usage +@subsection Personal timeline + +@firstparagraphindent none +To view your Personal timeline execute: +@* +@example +C-c C-f +@end example + +@node Update status, Send notice, Personal timeline, Basic usage +@subsection Update status + +@firstparagraphindent none +To update your Identica status execute: +@* +@example +C-c C-s +@end example + +@paragraphindent 3 +At the @code{Status:} prompt, type the content of your status, up to 140 characters. When done, hit the @command{Enter} key. The message @code{Success: Post} will apper in the minibuffer. + +@node Send notice, Shorten url, Update status, Basic usage +@subsection Send notice + +@firstparagraphindent none +To send a notice directly to a user execute: +@* +@example +C-c C-d +@end example + +@paragraphindent 3 +At the @code{To user:} prompt type the exact user name and press the @command{Enter} key. At the @code{Direct message:} prompt, type your message and press the @command{Enter} key. + +@node Shorten url, , Send notice, Basic usage +@subsection Shorten url + +@firstparagraphindent none +You can shorten a url while typing your update notice on the +minibuffer by pressing the @command{<F4>} key while the cursor is in +between or at the end of the long url you just typed. + +@node Tips and tricks, , Basic usage, Using identica-mode.el +@section Tips and tricks + +@menu +* Run commands after recieving notices:: +* Extending identica-mode:: +@end menu + +@node Run commands after recieving notices, , Tips and tricks, Tips and tricks +@subsection Run commands after recieving notices + +@firstparagraphindent none +You can now create ``hooks'' that will run after recieving new +notices. Just add a hook function to @code{identica-new-dents-hook}. + +@firstparagraphindent none +To display a notification message on KDE 4 you can add the following +code on your .emacs file: +@* +@example +;; KDE 4 Notification of new dents with kdialog +(add-hook 'identica-new-dents-hook (lambda () + (let ((n identica-new-dents-count)) + (start-process "identica-notify" nil "kdialog" + "--title" + "Emacs Identica-mode New dents" + "--passivepopup" + (format "You have %d new dent%s" + n (if (> n 1) "s" "")) + "3" +)))) +@end example + +@node Extending identica-mode, , Tips and tricks, Tips and tricks +@subsection Extending identica-mode + +@firstparagraphindent none +Because identica-mode.el is written in Emacs Lisp, there are many options to extend the mode to your liking. As this is the first release of the Identica mode manual, this section will serve to simply encourage you to experiment with the code, and to see @ref{Contributing} for ways to let us know how you've extended identica-mode.el - maybe we'll add your extensions to the code, and this section, in further releases! + +@node Credits and contributing, GNU Free Documentation License, Using identica-mode.el, Top +@chapter Credits and contributing + +@menu +* Credits:: +* Contributing:: +@end menu + +@node Credits, Contributing, Credits and contributing, Credits and contributing +@section Credits + +@firstparagraphindent none +The following individuals have contributed to the Identica mode project. See the identica-mode.el file for more information. + +@itemize @bullet +@item Christian Cheng +@item Alberto Garcia +@item Bradley M. Kuhn +@item Jason McBrayer +@item Carlos A. Perilla +@item Alex Schröder +@item Shyam Karanatt +@end itemize + +@node Contributing, , Credits, Credits and contributing +@section Contributing + +@firstparagraphindent none +If you have any ideas for features, patches or bug fixes, please add them to the identica-mode @uref{https://savannah.nongnu.org/bugs/?group=identica-mode, bug tracking list}. If you are submitting something specifically for @ref{Extending identica-mode}, be sure to note this in your ticket. + +@node GNU Free Documentation License, , Credits and contributing, Top +@unnumbered GNU Free Documentation License +@include fdl.texi + +@bye diff --git a/.emacs.d/identica-mode-1.1/identica-mode.el b/.emacs.d/identica-mode-1.1/identica-mode.el new file mode 100644 index 0000000..86ff386 --- /dev/null +++ b/.emacs.d/identica-mode-1.1/identica-mode.el @@ -0,0 +1,1853 @@ +;;; identica-mode.el --- Major mode for Identica + +;; Copyright (C) 2008, 2009, 2010 Gabriel Saldana +;; Copyright (C) 2009 Bradley M. Kuhn + +;; Author: Gabriel Saldana <gsaldana@gmail.com> +;; Last update: 2010-11-26 +;; Version: 1.1 +;; Keywords: identica web +;; URL: http://blog.nethazard.net/identica-mode-for-emacs/ +;; Contributors: +;; Jason McBrayer <jmcbray@carcosa.net> (minor updates for working under Emacs 23) +;; Alex Schröder <kensanata@gmail.com> (mode map patches) +;; Christian Cheng (fixed long standing xml parsing bug) +;; Carlos A. Perilla from denting-mode +;; Alberto Garcia <agarcia@igalia.com> (integrated patch from twittering-mode for retrieving multiplemethods) +;; Bradley M. Kuhn <bkuhn@ebb.org> (editing status from edit-buffer rather than minibuffer) +;; Jason McBrayer <jmcbray@carcosa.net> (replace group tags with hashtags on redents, longlines use) +;; Sean Neakums (patches of bugs flagged by byte-compiler) +;; Shyam Karanatt <shyam@swathanthran.in> (several patches and code cleanup, new http backend based on url.el) +;; Tezcatl Franco <tzk@riseup.net> (ur1.ca support) +;; Anthony Garcia <lagg@lavabit.com> (fix for icon-mode) + +;; Identica Mode is a major mode to check friends timeline, and update your +;; status on Emacs. + +;; identica-mode.el is a major mode for Identica. Based on the twittering mode +;; version 0.6 by Y. Hayamizu and Tsuyoshi CHO found at +;; <http://hayamin.com/wiliki.cgi?twittering-mode-en&l=en> + +;; This file is free software; you can redistribute it and/or modify +;; it under the terms of the GNU General Public License as published by +;; the Free Software Foundation; either version 2, or (at your option) +;; any later version. + +;; This file is distributed in the hope that it will be useful, +;; but WITHOUT ANY WARRANTY; without even the implied warranty of +;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +;; GNU General Public License for more details. + +;; You should have received a copy of the GNU General Public License +;; along with GNU Emacs; see the file COPYING. If not, write to +;; the Free Software Foundation, Inc., 51 Franklin Street, Fifth floor, +;; Boston, MA 02110-1301, USA. + +;; Requirements +;; if using Emacs22 or previous, you'll need json.el +;; get it from http://edward.oconnor.cx/2006/03/json.el +;; json.el is part of Emacs23 + +;; Installation + +;; You can use M-x customize-group identica-mode to setup all settings or simply +;; add the following to your .emacs or your prefered customizations file + +;; (require 'identica-mode) +;; (setq identica-username "yourusername") +;; (setq identica-password "yourpassword") + +;; If you want to post from the minibufer without having identica buffer active, add the following global keybinding. +;; Add this to send status updates +;; (global-set-key "\C-cip" 'identica-update-status-interactive) +;; Add this to send direct messages +;; (global-set-key "\C-cid" 'identica-direct-message-interactive) + +;; If you want to connect to a custom statusnet server add this and change +;; identi.ca with your server's doman name. + +;; (setq statusnet-server "identi.ca") + +;; Start using with M-x identica + +;; Follow me on identica: http://identi.ca/gabrielsaldana + +(require 'cl) +(require 'xml) +(require 'parse-time) +(require 'longlines) +(require 'url) +(require 'url-http) +(require 'json) + +(defconst identica-mode-version "1.1") + +;;url-basepath fix for emacs22 +(unless (fboundp 'url-basepath) + (defalias 'url-basepath 'url-file-directory)) + +(defgroup identica-mode nil + "Identica Mode for microblogging" + :tag "Microblogging" + :link '(url-link http://blog.nethazard.net/identica-mode-for-emacs/) + :group 'applications ) + +(defun identica-mode-version () + "Display a message for identica-mode version." + (interactive) + (let ((version-string + (format "identica-mode-v%s" identica-mode-version))) + (if (interactive-p) + (message "%s" version-string) + version-string))) + +(defvar identica-mode-map (make-sparse-keymap "Identi.ca")) +(defvar menu-bar-identica-mode-menu nil) +(defvar identica-timer nil "Timer object for timeline refreshing will be stored here. DO NOT SET VALUE MANUALLY.") +(defvar identica-last-timeline-retrieved nil) + +(defvar identica-urlshortening-services-map + '((tinyurl . "http://tinyurl.com/api-create.php?url=") + (toly . "http://to.ly/api.php?longurl=") + (google . "http://ggl-shortener.appspot.com/?url=") + (ur1ca . "http://ur1.ca") + (tighturl . "http://2tu.us")) + "Alist of tinyfy services") + +(defvar identica-new-dents-count 0 + "Number of new tweets when `identica-new-dents-hook' is run") + +(defvar identica-new-dents-hook nil + "Hook run when new twits are received. + +You can read `identica-new-dents-count' to get the number of new +tweets received when this hook is run.") + +(defvar identica-display-max-dents nil + "How many dents to keep on the displayed timeline. + +If non-nil, dents over this amount will bre removed.") + +;; Menu +(unless menu-bar-identica-mode-menu + (easy-menu-define + menu-bar-identica-mode-menu identica-mode-map "" + '("Identi.ca" + ["Send an update" identica-update-status-interactive t] + ["Send a direct message" identica-direct-message-interactive t] + ["Re-dent someone's update" identica-redent t] + ["Repeat someone's update" identica-repeat t] + ["Add as favorite" identica-favorite t] + ["Follow user" identica-follow] + ["Unfollow user" identica-unfollow] + ["--" nil nil] + ["Friends timeline" identica-friends-timeline t] + ["Public timeline" identica-public-timeline t] + ["Replies timeline" identica-replies-timeline t] + ["User timeline" identica-user-timeline t] + ["Group timeline" identica-group-timeline t] + ["Tag timeline" identica-tag-timeline t] +))) + +(defcustom identica-idle-time 20 + "Idle time" + :type 'integer + :group 'identica-mode) + +(defcustom identica-timer-interval 90 + "Timer interval to refresh the timeline" + :type 'integer + :group 'identica-mode) + +(defcustom identica-username nil + "Your identi.ca username. If nil, you will be prompted" + :type '(choice (const :tag "Ask" nil) (string)) + :group 'identica-mode) + +(defcustom identica-password nil + "Your identi.ca password. If nil, you will be prompted" + :type '(choice (const :tag "Ask" nil) (string)) + :group 'identica-mode) + +(defcustom statusnet-server "identi.ca" + "Statusnet instance url" + :type 'string + :group 'identica-mode) + +(defcustom statusnet-port 80 + "Port on which StatusNet instance listens" + :type 'integer + :group 'identica-mode) + +(defcustom identica-default-timeline "friends_timeline" + "Default timeline to retrieve" + :type 'string + :options '("friends_timeline" "public_timeline" "replies") + :group 'identica-mode) + +(defcustom identica-display-success-messages nil + "Display messages when the timeline is successfully retrieved" + :type 'boolean + :group 'identica-mode) + +(defcustom identica-oldest-first nil + "If t, display older messages before newer ones" + :type 'boolean + :group 'identica-mode) + +(defcustom identica-update-status-edit-confirm-cancellation nil + "If t, ask user if they are sure when aborting editing of an + identica status update when using an edit-buffer" + :type 'boolean + :group 'identica-mode) + +(defcustom identica-soft-wrap-status nil + "If non-nil, don't fill status messages in the timeline as + paragraphs. Instead, use visual-line-mode or longlines-mode if + available to wrap messages. This may work better for narrow + timeline windows." + :type 'boolean + :group 'identica-mode) + +(defcustom identica-update-status-method 'minibuffer + "Method for performaing status updates. + +The available choices are: + + 'minibuffer - edit the status update in the minibuffer. + 'edit-buffer - edit the status update in an independent buffer." + :type '(choice (const :tag "Edit status in minibuffer" minibuffer) + (const :tag "Edit status in independent buffer" edit-buffer)) + :group 'identica-mode) + +(defcustom identica-http-get-timeout 10 + "Controls how long to wait for a response from the server." + :type 'integer + :group 'identica-mode) + +;; Initialize with default timeline +(defvar identica-method identica-default-timeline) +(defvar identica-method-class "statuses") + +(defvar identica-scroll-mode nil) +(make-variable-buffer-local 'identica-scroll-mode) + +(defvar identica-source "identica-mode") + +(defcustom identica-redent-format "♻" + "The format/symbol to represent redents" + :type 'string + :group 'identica-mode) + +(defcustom identica-status-format "%i %s, %@:\n %t // from %f%L%r" + "The format used to display the status updates" + :type 'string + :group 'identica-mode) +;; %s - screen_name +;; %S - name +;; %i - profile_image +;; %d - description +;; %l - location +;; %L - " [location]" +;; %r - in reply to status +;; %u - url +;; %j - user.id +;; %p - protected? +;; %c - created_at (raw UTC string) +;; %C{time-format-str} - created_at (formatted with time-format-str) +;; %@ - X seconds ago +;; %t - text +;; %' - truncated +;; %f - source +;; %# - id + +(defcustom identica-urlshortening-service 'ur1ca + "The service to use for URL shortening. Values understood are +ur1ca, tighturl, tinyurl, toly, and google" + :type 'symbol + :group 'identica-mode) + +(defvar identica-buffer "*identica*") +(defun identica-buffer (&optional method) + (unless method + (setq method "friends_timeline")) + (identica-get-or-generate-buffer identica-buffer)) + +(defvar identica-http-buffer nil + "Pointer to the current http response buffer.") + +(defvar identica-timeline-data nil) +(defvar identica-timeline-last-update nil) + +(defvar identica-username-face 'identica-username-face) +(defvar identica-uri-face 'identica-uri-face) +(defvar identica-reply-face 'identica-reply-face) + +(defun identica-get-or-generate-buffer (buffer) + (if (bufferp buffer) + (if (buffer-live-p buffer) + buffer + (generate-new-buffer (buffer-name buffer))) + (if (stringp buffer) + (or (get-buffer buffer) + (generate-new-buffer buffer))))) + +(defun assocref (item alist) + (cdr (assoc item alist))) +(defmacro list-push (value listvar) + `(setq ,listvar (cons ,value ,listvar))) + +;;; Proxy +(defvar identica-proxy-use nil) +(defvar identica-proxy-server nil) +(defvar identica-proxy-port 8080) +(defvar identica-proxy-user nil) +(defvar identica-proxy-password nil) + +(defun identica-toggle-proxy () "" + (interactive) + (setq identica-proxy-use + (not identica-proxy-use)) + (message "%s %s" + "Use Proxy:" + (if identica-proxy-use + "on" "off"))) + +(defun identica-user-agent-default-function () + "Identica mode default User-Agent function." + (concat "Emacs/" + (int-to-string emacs-major-version) "." (int-to-string + emacs-minor-version) + " " + "Identica-mode/" + identica-mode-version)) + +(defvar identica-user-agent-function 'identica-user-agent-default-function) + +(defun identica-user-agent () + "Return User-Agent header string." + (funcall identica-user-agent-function)) + +;;; to show image files + +(defvar identica-tmp-dir + (expand-file-name (concat "identicamode-images-" (user-login-name)) + temporary-file-directory)) + +(defvar identica-icon-mode nil "You MUST NOT CHANGE this variable directory. You should change through function'identica-icon-mode'") +(make-variable-buffer-local 'identica-icon-mode) +(defun identica-icon-mode (&optional arg) + (interactive) + (setq identica-icon-mode + (if identica-icon-mode + (if (null arg) + nil + (> (prefix-numeric-value arg) 0)) + (when (or (null arg) + (and arg (> (prefix-numeric-value arg) 0))) + (when (file-writable-p identica-tmp-dir) + (progn + (if (not (file-directory-p identica-tmp-dir)) + (make-directory identica-tmp-dir)) + t))))) + (identica-get-timeline)) + +(defun identica-scroll-mode (&optional arg) + (interactive) + (setq identica-scroll-mode + (if (null arg) + (not identica-scroll-mode) + (> (prefix-numeric-value arg) 0)))) + +(defvar identica-image-stack nil) + +(defun identica-image-type (file-name) + (cond + ((string-match "\\.jpe?g" file-name) 'jpeg) + ((string-match "\\.png" file-name) 'png) + ((string-match "\\.gif" file-name) 'gif) + (t nil))) + +(defun identica-setftime (fmt string uni) + (format-time-string fmt ; like "%Y-%m-%d %H:%M:%S" + (apply 'encode-time (parse-time-string string)) + uni)) +(defun identica-local-strftime (fmt string) + (identica-setftime fmt string nil)) +(defun identica-global-strftime (fmt string) + (identica-setftime fmt string t)) + +(defvar identica-debug-mode nil) +(defvar identica-debug-buffer "*identica-debug*") +(defun identica-debug-buffer () + (identica-get-or-generate-buffer identica-debug-buffer)) +(defmacro debug-print (obj) + (let ((obsym (gensym))) + `(let ((,obsym ,obj)) + (if identica-debug-mode + (with-current-buffer (identica-debug-buffer) + (insert (prin1-to-string ,obsym)) + (newline) + ,obsym) + ,obsym)))) + +(defun identica-debug-mode () + (interactive) + (setq identica-debug-mode + (not identica-debug-mode)) + (message (if identica-debug-mode "debug mode:on" "debug mode:off"))) + +(defun identica-delete-notice () + (interactive) + (let ((id (get-text-property (point) 'id)) + (usern (get-text-property (point) 'username))) + (if (string= usern identica-username) + (when (y-or-n-p "Delete this notice? ") + (identica-http-post "statuses/destroy" (number-to-string id)) + (identica-get-timeline)) + (message "Can't delete a notice that isn't yours")))) + +(if identica-mode-map + (let ((km identica-mode-map)) + (define-key km "\C-c\C-f" 'identica-friends-timeline) +;; (define-key km "\C-c\C-i" 'identica-direct-messages-timeline) + (define-key km "\C-c\C-r" 'identica-replies-timeline) + (define-key km "\C-c\C-a" 'identica-public-timeline) + (define-key km "\C-c\C-g" 'identica-group-timeline) + (define-key km "\C-c\C-t" 'identica-tag-timeline) + (define-key km "\C-c\C-k" 'identica-stop) + (define-key km "\C-c\C-u" 'identica-user-timeline) + (define-key km "\C-c\C-s" 'identica-update-status-interactive) + (define-key km "\C-c\C-d" 'identica-direct-message-interactive) + (define-key km "\C-c\C-m" 'identica-redent) + (define-key km "r" 'identica-repeat) + (define-key km "F" 'identica-favorite) + (define-key km "\C-c\C-e" 'identica-erase-old-statuses) + (define-key km "\C-m" 'identica-enter) + (define-key km "R" 'identica-reply-to-user) + (define-key km "\t" 'identica-next-link) + (define-key km [backtab] 'identica-prev-link) + (define-key km [mouse-1] 'identica-click) + (define-key km "\C-c\C-v" 'identica-view-user-page) + (define-key km "q" 'bury-buffer) + (define-key km "j" 'identica-goto-next-status) + (define-key km "k" 'identica-goto-previous-status) + (define-key km "l" 'forward-char) + (define-key km "h" 'backward-char) + (define-key km "0" 'beginning-of-line) + (define-key km "^" 'beginning-of-line-text) + (define-key km "$" 'end-of-line) + (define-key km "n" 'identica-goto-next-status-of-user) + (define-key km "p" 'identica-goto-previous-status-of-user) + (define-key km [backspace] 'scroll-down) + (define-key km " " 'scroll-up) + (define-key km "G" 'end-of-buffer) + (define-key km "g" 'identica-current-timeline) + (define-key km "H" 'beginning-of-buffer) + (define-key km "i" 'identica-icon-mode) + (define-key km "s" 'identica-scroll-mode) + (define-key km "t" 'identica-toggle-proxy) + (define-key km "\C-k" 'identica-delete-notice) + (define-key km "\C-c\C-p" 'identica-toggle-proxy) + nil)) + +(defvar identica-mode-syntax-table nil "") + +(if identica-mode-syntax-table + () + (setq identica-mode-syntax-table (make-syntax-table)) + ;; (modify-syntax-entry ? "" identica-mode-syntax-table) + (modify-syntax-entry ?\" "w" identica-mode-syntax-table)) + +(defun identica-mode-init-variables () + ;; (make-variable-buffer-local 'variable) + ;; (setq variable nil) + (font-lock-mode -1) + (defface identica-username-face + `((t nil)) "" :group 'faces) + (copy-face 'font-lock-string-face 'identica-username-face) + (set-face-attribute 'identica-username-face nil :underline t) + (defface identica-reply-face + `((t nil)) "" :group 'faces) + (copy-face 'font-lock-string-face 'identica-reply-face) + (set-face-attribute 'identica-reply-face nil :foreground "white") + (set-face-attribute 'identica-reply-face nil :background "DarkSlateGray") + (defface identica-uri-face + `((t nil)) "" :group 'faces) + + (set-face-attribute 'identica-uri-face nil :underline t) + (add-to-list 'minor-mode-alist '(identica-icon-mode " id-icon")) + (add-to-list 'minor-mode-alist '(identica-scroll-mode " id-scroll"))) + +(defmacro case-string (str &rest clauses) + `(cond + ,@(mapcar + (lambda (clause) + (let ((keylist (car clause)) + (body (cdr clause))) + `(,(if (listp keylist) + `(or ,@(mapcar (lambda (key) `(string-equal ,str ,key)) keylist)) + 't) + ,@body))) + clauses))) + +;; If you use Emacs21, decode-char 'ucs will fail unless Mule-UCS is loaded. +;; TODO: Show error messages if Emacs 21 without Mule-UCS +(defmacro identica-ucs-to-char (num) + (if (functionp 'ucs-to-char) + `(ucs-to-char ,num) + `(decode-char 'ucs ,num))) + +(defvar identica-mode-string identica-method) + +(defun identica-set-mode-string (loading) + (setq mode-name + (if loading (concat "loading " identica-method "...") identica-method))) + +(defvar identica-mode-hook nil + "Identica-mode hook.") + +(defun identica-kill-buffer-function () + (when (eq major-mode 'identica-mode) + (identica-stop))) + +(defun identica-mode () + "Major mode for Identica +\\{identica-mode-map}" + (interactive) + (switch-to-buffer (identica-buffer)) + (buffer-disable-undo (identica-buffer)) + (kill-all-local-variables) + (identica-mode-init-variables) + (use-local-map identica-mode-map) + (setq major-mode 'identica-mode) + (setq mode-name identica-mode-string) + (setq mode-line-buffer-identification + `(,(default-value 'mode-line-buffer-identification) + (:eval (identica-mode-line-buffer-identification)))) + (identica-update-mode-line) + (set-syntax-table identica-mode-syntax-table) + (font-lock-mode -1) + (if identica-soft-wrap-status + (if (fboundp 'visual-line-mode) + (visual-line-mode t) + (if (fboundp 'longlines-mode) + (longlines-mode t)))) + (identica-start) + (add-hook 'kill-buffer-hook 'identica-kill-buffer-function) + (run-mode-hooks 'identica-mode-hook)) + +;;; +;;; Basic HTTP functions +;;; + +(defun identica-set-proxy (&optional url username passwd server port) + "Sets the proxy authentication variables as required by url +library.When called with no arguments, it reads `identica-mode' proxy +variables to get the authentication parameters.URL is either a string +or parsed URL. If URL is non-nil and valid, proxy authentication +values are read from it.the rest of the arguments can be used to +directly set proxy authentication.This function essentially adds +authentication parameters from one of the above methods to the double +alist `url-http-proxy-basic-auth-storage' and sets `url-using-proxy'." + (let* ((href (if (stringp url) + (url-generic-parse-url url) + url)) + (port (or (and href (url-port href)) + port identica-proxy-port)) + (port (if (integerp port) (int-to-string port) port)) + (server (or (and href (url-host href)) + server identica-proxy-server)) + (server (and server + (concat server (when port (concat ":" port))))) + (file (if href (let ((file-url (url-filename href))) + (cond + ((string= "" file-url) "/") + ((string-match "/$" file-url) file-url) + (t (url-basepath file-url)))) + "Proxy")) + (password (or (and href (url-password href)) + passwd identica-proxy-password)) + (auth (concat (or (and href (url-user href)) + username identica-proxy-user) + (and password (concat ":" password))))) + (when (and identica-proxy-use + (not (string= "" server)) + (not (string= "" auth))) + (setq url-using-proxy server) + (let* ((proxy-double-alist + (or (assoc server + url-http-proxy-basic-auth-storage) + (car (push (cons server nil) + url-http-proxy-basic-auth-storage)))) + (proxy-auth-alist (assoc file proxy-double-alist))) + (if proxy-auth-alist + (setcdr proxy-auth-alist (base64-encode-string auth)) + (setcdr proxy-double-alist + (cons (cons file + (base64-encode-string auth)) + (cdr-safe proxy-double-alist)))))))) + +(defun identica-change-user () + (interactive) + "Interactive function to instantly change user authentication by +directly reading parameters from user. This function only sets the +identica-mode variables `identica-username' and +`identica-password'. +It is the `identica-set-auth' function that eventually sets the +url library variables according to the above variables which does the +authentication. This will be done automatically in normal use cases +enabling dynamic change of user authentication." + (setq identica-username + (read-string (concat "Username [for " statusnet-server + ":" (int-to-string statusnet-port) "]: ") + nil nil identica-username) + identica-password + (read-passwd "Password: " nil identica-password)) + (identica-get-timeline)) + +(defun identica-set-auth (&optional url username passwd server port) + "Sets the authentication parameters as required by url library. +If URL is non-nil and valid, it reads user authentication +parameters from url. +If URL is nil, Rest of the arguments can be used to directly set user +authentication. +When called with no arguments, user authentication parameters are +read from identica-mode variables `identica-username' +`identica-password' `statusnet-server' `statusnet-port'." + (let* ((href (if (stringp url) + (url-generic-parse-url url) + url)) + (port (or (and href (url-port href)) + port statusnet-port)) + (port (if (integerp port) (int-to-string port) port)) + (server (or (and href (url-host href)) + server statusnet-server)) + (server (and server + (concat server (when port (concat ":" port))))) + (file (if href (let ((file-url (url-filename href))) + (cond + ((string= "" file-url) "/") + ((string-match "/$" file-url) file-url) + (t (url-basepath file-url)))) + "Identi.ca API")) + (password (or (and href (url-password href)) + passwd identica-password)) + (auth (concat (or (and href (url-user href)) + username identica-username) + (and password (concat ":" password))))) + (when (and (not (string= "" server)) + (not (string= "" auth))) + (let* ((server-double-alist + (or (assoc server + url-http-real-basic-auth-storage) + (car (push (cons server nil) + url-http-real-basic-auth-storage)))) + (api-auth-alist (assoc file server-double-alist))) + (if api-auth-alist + (setcdr api-auth-alist (base64-encode-string auth)) + (setcdr server-double-alist + (cons (cons file + (base64-encode-string auth)) + (cdr-safe server-double-alist)))))))) + +(defun identica-http-get (method-class method &optional parameters + sentinel sentinel-arguments) + "Basic function which communicates with server. +METHOD-CLASS and METHOD are parameters for getting dents messages and +other information from server as specified in api documentation. +Third optional arguments specify the additional parameters required by +the above METHOD. It is specified as an alist with parameter name and +its corresponding value +SENTINEL represents the callback function to be called after the http +response is completely retrieved. SENTINEL-ARGUMENTS is the list of +arguments (if any) of the SENTINEL procedure." + (or sentinel (setq sentinel 'identica-http-get-default-sentinel)) + (let ((url (concat "http://" statusnet-server "/api/" + (when (not (string-equal method-class "none")) + (concat method-class "/" )) + method ".xml" + (when parameters + (concat "?" + (mapconcat + (lambda (param-pair) + (format "%s=%s" + (identica-percent-encode (car param-pair)) + (identica-percent-encode (cdr param-pair)))) + parameters + "&"))))) + (url-package-name "emacs-identica-mode") + (url-package-version identica-mode-version) + (url-show-status nil)) + (identica-set-proxy) + (identica-set-auth url) + (when (get-buffer-process identica-http-buffer) + (delete-process identica-http-buffer) + (kill-buffer identica-http-buffer)) + (setq identica-http-buffer + (url-retrieve url sentinel + (append (list method-class method parameters) + sentinel-arguments))) + (save-excursion + (set-buffer identica-buffer) + (identica-set-mode-string t)))) + +(defun identica-http-get-default-sentinel + (&optional status method-class method parameters success-message) + (cond ((setq error-object + (or (assoc :error status) + (and (equal :error (car status)) + (cadr status)))) + (let ((error-data (format "%s" (caddr error-object)))) + (when (cond + ((string= error-data "deleted\n") t) + ((and (string= error-data "404") method + (= 13 (string-match "/" method))) + (message "No Such User: %s" (substring method 14)) + t) + ((y-or-n-p + (format "Identica-Mode: Network error:%s Retry? " + status)) + (identica-http-get method-class method parameters) + nil)) + ;; when the network process is deleted by another query + ;; or the user queried is not found , query is _finished_ + ;; unsuccessful and we want to restore identica-method + ;; to loose track of this unsuccessful attempt + (setq identica-method identica-last-timeline-retrieved)))) + ((< (- (point-max) (or (re-search-forward ">\r?\n\r*$" nil t) 0)) 2) + ;;Checking the whether the message is complete by + ;;searching for > that closes the last tag, followed by + ;;CRLF at (point-max) + (when (setq body (identica-get-response-body)) + (setq identica-new-dents-count + (count t (mapcar + #'identica-cache-status-datum + (reverse (identica-xmltree-to-status + body))))) + ; Shorten the timeline if necessary + (if (and identica-display-max-dents + (> (safe-length identica-timeline-data) + identica-display-max-dents)) + (cl-set-nthcdr identica-display-max-dents + identica-timeline-data nil)) + (identica-render-timeline) + (if (> identica-new-dents-count 0) + (run-hooks 'identica-new-dents-hook)) + (when identica-display-success-messages + (message (or success-message "Success: Get")))))) + (unless (get-buffer-process (current-buffer)) + (kill-buffer (current-buffer)))) + +(defun identica-render-timeline () + (with-current-buffer (identica-buffer) + (let ((point (point)) + (end (point-max)) + (wrapped (cond (longlines-mode 'longlines-mode) + (visual-line-mode 'visual-line-mode) + (t nil)))) + + (setq buffer-read-only nil) + (erase-buffer) + (when wrapped (funcall wrapped -1)) + (mapc (lambda (status) + (insert (identica-format-status + status identica-status-format)) + (if (not wrapped) + (progn + (fill-region-as-paragraph + (save-excursion (beginning-of-line) (point)) (point)))) + (insert "\n") + (if identica-oldest-first + (goto-char (point-min)))) + identica-timeline-data) + (if (and identica-image-stack window-system) + (clear-image-cache)) + (when wrapped (funcall wrapped 1)) + (setq buffer-read-only t) + (debug-print (current-buffer)) + (goto-char (+ point (if identica-scroll-mode (- (point-max) end) 0))) + (identica-set-mode-string nil) + (setq identica-last-timeline-retrieved identica-method) + (if transient-mark-mode (deactivate-mark))))) + +(defun identica-format-status (status format-str) + (flet ((attr (key) + (assocref key status)) + (profile-image + () + (let ((profile-image-url (attr 'user-profile-image-url)) + (icon-string "\n ")) + (if (string-match "/\\([^/?]+\\)\\(?:\\?\\|$\\)" profile-image-url) + (let ((filename (match-string-no-properties 1 profile-image-url))) + ;; download icons if does not exist + (if (file-exists-p (concat identica-tmp-dir + "/" filename)) + t + (add-to-list 'identica-image-stack profile-image-url)) + + (when (and icon-string identica-icon-mode) + (set-text-properties + 1 2 `(display ,(create-image (concat identica-tmp-dir "/" filename))) + icon-string) + icon-string)))))) + (let ((cursor 0) + (result ()) + c + found-at) + (setq cursor 0) + (setq result '()) + (while (setq found-at (string-match "%\\(C{\\([^}]+\\)}\\|[A-Za-z#@']\\)" format-str cursor)) + (setq c (string-to-char (match-string-no-properties 1 format-str))) + (if (> found-at cursor) + (list-push (substring format-str cursor found-at) result) + "|") + (setq cursor (match-end 1)) + + (case c + ((?s) ; %s - screen_name + (list-push (attr 'user-screen-name) result)) + ((?S) ; %S - name + (list-push (attr 'user-name) result)) + ((?i) ; %i - profile_image + (list-push (profile-image) result)) + ((?d) ; %d - description + (list-push (attr 'user-description) result)) + ((?l) ; %l - location + (list-push (attr 'user-location) result)) + ((?L) ; %L - " [location]" + (let ((location (attr 'user-location))) + (unless (or (null location) (string= "" location)) + (list-push (concat " [" location "]") result)) )) + ((?u) ; %u - url + (list-push (attr 'user-url) result)) + ((?j) ; %j - user.id + (list-push (format "%d" (attr 'user-id)) result)) + ((?r) ; %r - in_reply_to_status_id + (let ((reply-id (attr 'in-reply-to-status-id)) + (reply-name (attr 'in-reply-to-screen-name))) + (unless (or (null reply-id) (string= "" reply-id) + (null reply-name) (string= "" reply-name)) + (let ((in-reply-to-string (format "in reply to %s" reply-name)) + (url (identica-get-status-url reply-id))) + (add-text-properties + 0 (length in-reply-to-string) + `(mouse-face highlight + face identica-uri-face + uri ,url) + in-reply-to-string) + (list-push (concat " " in-reply-to-string) result))))) + ((?p) ; %p - protected? + (let ((protected (attr 'user-protected))) + (when (string= "true" protected) + (list-push "[x]" result)))) + ((?c) ; %c - created_at (raw UTC string) + (list-push (attr 'created-at) result)) + ((?C) ; %C{time-format-str} - created_at (formatted with time-format-str) + (list-push (identica-local-strftime + (or (match-string-no-properties 2 format-str) "%H:%M:%S") + (attr 'created-at)) + result)) + ((?@) ; %@ - X seconds ago + (let ((created-at + (apply + 'encode-time + (parse-time-string (attr 'created-at)))) + (now (current-time))) + (let ((secs (+ (* (- (car now) (car created-at)) 65536) + (- (cadr now) (cadr created-at)))) + time-string url) + (setq time-string + (cond ((< secs 5) "less than 5 seconds ago") + ((< secs 10) "less than 10 seconds ago") + ((< secs 20) "less than 20 seconds ago") + ((< secs 30) "half a minute ago") + ((< secs 60) "less than a minute ago") + ((< secs 150) "1 minute ago") + ((< secs 2400) (format "%d minutes ago" + (/ (+ secs 30) 60))) + ((< secs 5400) "about 1 hour ago") + ((< secs 84600) (format "about %d hours ago" + (/ (+ secs 1800) 3600))) + (t (format-time-string "%I:%M %p %B %d, %Y" created-at)))) + (setq url (identica-get-status-url (attr 'id))) + ;; make status url clickable + (add-text-properties + 0 (length time-string) + `(mouse-face highlight + face identica-uri-face + uri ,url) + time-string) + (list-push time-string result)))) + ((?t) ; %t - text + (list-push ;(clickable-text) + (attr 'text) + result)) + ((?') ; %' - truncated + (let ((truncated (attr 'truncated))) + (when (string= "true" truncated) + (list-push "..." result)))) + ((?f) ; %f - source + (list-push (attr 'source) result)) + ((?#) ; %# - id + (list-push (format "%d" (attr 'id)) result)) + (t + (list-push (char-to-string c) result)))) + (list-push (substring format-str cursor) result) + (let ((formatted-status (apply 'concat (nreverse result)))) + (add-text-properties 0 (length formatted-status) + `(username ,(attr 'user-screen-name) + id, (attr 'id) + text ,(attr 'text)) + formatted-status) + formatted-status)))) + +(defun identica-http-post + (method-class method &optional parameters sentinel sentinel-arguments) + "Send HTTP POST request to statusnet server +METHOD-CLASS must be one of Identica API method classes(statuses, users or direct_messages). +METHOD must be one of Identica API method which belongs to METHOD-CLASS. +PARAMETERS is alist of URI parameters. ex) ((\"mode\" . \"view\") (\"page\" . \"6\")) => <URI>?mode=view&page=6" + (or sentinel (setq sentinel 'identica-http-post-default-sentinel)) + (let ((url-request-method "POST") + (url (concat "http://"statusnet-server "/api/" method-class "/" method ".xml" + (when parameters + (concat "?" + (mapconcat + (lambda (param-pair) + (format "%s=%s" + (identica-percent-encode (car param-pair)) + (identica-percent-encode (cdr param-pair)))) + parameters + "&"))))) + (url-package-name "emacs-identicamode") + (url-package-version identica-mode-version) + (url-request-extra-headers '(("Content-Length" . "0"))) + (url-show-status nil)) + (identica-set-proxy) + (identica-set-auth url) + (when (get-buffer-process identica-http-buffer) + (delete-process identica-http-buffer) + (kill-buffer identica-http-buffer)) + (url-retrieve url sentinel + (append (list method-class method parameters) + sentinel-arguments)))) + +(defun identica-http-post-default-sentinel + (&optional status method-class method parameters success-message) + (cond ((and + (setq error-object (or (assoc :error status) + (and (equal :error (car status)) + (cadr status)))) + (y-or-n-p (format "Network error:%s %s Retry?" + (cadr error-object) + (caddr error-object)))) + (identica-http-post method-class method parameters nil success-message)) + (identica-display-success-messages + (message (or success-message "Success: Post")))) + (unless (get-buffer-process (current-buffer)) + (kill-buffer (current-buffer)))) + +(defun identica-get-response-header (&optional buffer) + "Exract HTTP response header from HTTP response. +`buffer' may be a buffer or the name of an existing buffer. + If `buffer' is omitted, current-buffer is parsed." + (or buffer + (setq buffer (current-buffer))) + (save-excursion + (set-buffer buffer) + (let ((end (or (and (search-forward-regexp "\r?\n\r?\n" (point-max) t) + (match-beginning 0)) + 0))) + (and (> end 1) + (buffer-substring (point-min) end))))) + +(defun identica-get-response-body (&optional buffer) + "Exract HTTP response body from HTTP response, parse it as XML, and return a XML tree as list. +`buffer' may be a buffer or the name of an existing buffer. + If `buffer' is omitted, current-buffer is parsed." + (or buffer + (setq buffer (current-buffer))) + (save-excursion + (set-buffer buffer) + (set-buffer-multibyte t) + (let ((start (save-excursion + (goto-char (point-min)) + (and (re-search-forward "<\?xml" (point-max) t) + (match-beginning 0))))) + (identica-clean-response-body) + (and start + (xml-parse-region start (point-max)))))) + +(defun identica-clean-weird-chars (&optional buffer) +;;(if (null buffer) (setq buffer (identica-http-buffer))) +(with-current-buffer (identica-http-buffer) + (goto-char (point-min)) + (while (re-search-forward "\ + +? +[0-9a-z]*\ + +? +?" nil t) +(replace-match "")) +(buffer-string))) + +(defun identica-clean-response-body () + "Removes weird strings (e.g., 1afc, a or 0) from within the +response body. Known Statusnet issue. Mostly harmless except if +in tags." + (goto-char (point-min)) + (while (re-search-forward "\r?\n[0-9a-z]+\r?\n" nil t) + (replace-match ""))) + +(defun identica-cache-status-datum (status-datum &optional data-var) + "Cache status datum into data-var(default identica-timeline-data) +If STATUS-DATUM is already in DATA-VAR, return nil. If not, return t." + (if (null data-var) + (setf data-var 'identica-timeline-data)) + (let ((id (cdr (assq 'id status-datum)))) + (if (or (null (symbol-value data-var)) + (not (find-if + (lambda (item) + (eql id (cdr (assq 'id item)))) + (symbol-value data-var)))) + (progn + (set data-var (cons status-datum (symbol-value data-var))) + t) + nil))) + +(defun identica-status-to-status-datum (status) + (flet ((assq-get (item seq) + (car (cddr (assq item seq))))) + (let* ((status-data (cddr status)) + id text source created-at truncated + in-reply-to-status-id + in-reply-to-screen-name + (user-data (cddr (assq 'user status-data))) + user-id user-name + user-screen-name + user-location + user-description + user-profile-image-url + user-url + user-protected + regex-index) + + (setq id (string-to-number (assq-get 'id status-data))) + (setq text (identica-decode-html-entities + (assq-get 'text status-data))) + (setq source (identica-decode-html-entities + (assq-get 'source status-data))) + (setq created-at (assq-get 'created_at status-data)) + (setq truncated (assq-get 'truncated status-data)) + (setq in-reply-to-status-id + (identica-decode-html-entities + (assq-get 'in_reply_to_status_id status-data))) + (setq in-reply-to-screen-name + (identica-decode-html-entities + (assq-get 'in_reply_to_screen_name status-data))) + (setq user-id (string-to-number (assq-get 'id user-data))) + (setq user-name (identica-decode-html-entities + (assq-get 'name user-data))) + (setq user-screen-name (identica-decode-html-entities + (assq-get 'screen_name user-data))) + (setq user-location (identica-decode-html-entities + (assq-get 'location user-data))) + (setq user-description (identica-decode-html-entities + (assq-get 'description user-data))) + (setq user-profile-image-url (assq-get 'profile_image_url user-data)) + (setq user-url (assq-get 'url user-data)) + (setq user-protected (assq-get 'protected user-data)) + + ;; make username clickable + (add-text-properties + 0 (length user-name) + `(mouse-face highlight + uri ,(concat "https://" statusnet-server "/" user-screen-name) + face identica-username-face) + user-name) + + ;; make screen-name clickable + (add-text-properties + 0 (length user-screen-name) + `(mouse-face highlight + face identica-username-face + uri ,(concat "https://" statusnet-server "/" user-screen-name) + face identica-username-face) + user-screen-name) + + ;; make URI clickable + (setq regex-index 0) + (while regex-index + (setq regex-index + (string-match "@\\([_[:word:]0-9]+\\)\\|!\\([_[:word:]0-9\-]+\\)\\|#\\([_[:word:]0-9\-]+\\)\\|\\(ur1\.ca/[a-z0-9]+/?\\|https?://[-_.!~*'()[:word:]0-9\;/?:@&=+$,%#]+\\)" + text + regex-index)) + (when regex-index + (let* ((matched-string (match-string-no-properties 0 text)) + (screen-name (match-string-no-properties 1 text)) + (group-name (match-string-no-properties 2 text)) + (tag-name (match-string-no-properties 3 text)) + (uri (match-string-no-properties 4 text))) + (add-text-properties + (if (or screen-name group-name tag-name) + (+ 1 (match-beginning 0)) + (match-beginning 0)) + (match-end 0) + (if (or screen-name group-name tag-name) + `(mouse-face + highlight + face identica-uri-face + uri ,(if screen-name + (concat "https://" statusnet-server "/" screen-name) + (if group-name + (concat "https://" statusnet-server "/group/" group-name) + (concat "https://" statusnet-server "/tag/" tag-name))) + uri-in-text ,(if screen-name + (concat "https://" statusnet-server "/" screen-name) + (if group-name + (concat "https://" statusnet-server "/group/" group-name) + (concat "https://" statusnet-server "/tag/" tag-name))) + tag ,tag-name + group ,group-name) + `(mouse-face highlight + face identica-uri-face + uri ,uri + uri-in-text ,uri)) + text)) + (setq regex-index (match-end 0)) )) + + + ;; make source pretty and clickable + (if (string-match "<a href=\"\\(.*\\)\">\\(.*\\)</a>" source) + (let ((uri (match-string-no-properties 1 source)) + (caption (match-string-no-properties 2 source))) + (setq source caption) + (add-text-properties + 0 (length source) + `(mouse-face highlight + face identica-uri-face + source ,source) + source))) + + ;; save last update time + (setq identica-timeline-last-update created-at) + + ;; highlight replies + (if (string-match (concat "@" identica-username) text) + (add-text-properties 0 (length text) + `(face identica-reply-face) text)) + (mapcar + (lambda (sym) + `(,sym . ,(symbol-value sym))) + '(id text source created-at truncated + in-reply-to-status-id + in-reply-to-screen-name + user-id user-name user-screen-name user-location + user-description + user-profile-image-url + user-url + user-protected))))) + +(defun identica-xmltree-to-status (xmltree) + (mapcar #'identica-status-to-status-datum + ;; quirk to treat difference between xml.el in Emacs21 and Emacs22 + ;; On Emacs22, there may be blank strings + (let ((ret nil) (statuses (reverse (cddr (car xmltree))))) + (while statuses + (if (consp (car statuses)) + (setq ret (cons (car statuses) ret))) + (setq statuses (cdr statuses))) + ret))) + +(defun identica-percent-encode (str &optional coding-system) + (if (or (null coding-system) + (not (coding-system-p coding-system))) + (setq coding-system 'utf-8)) + (mapconcat + (lambda (c) + (cond + ((identica-url-reserved-p c) + (char-to-string c)) + ((eq c ? ) "+") + (t (format "%%%x" c)))) + (encode-coding-string str coding-system) + "")) + +(defun identica-url-reserved-p (ch) + (or (and (<= ?A ch) (<= ch ?z)) + (and (<= ?0 ch) (<= ch ?9)) + (eq ?. ch) + (eq ?- ch) + (eq ?_ ch) + (eq ?~ ch))) + +(defun identica-decode-html-entities (encoded-str) + (if encoded-str + (let ((cursor 0) + (found-at nil) + (result '())) + (while (setq found-at + (string-match "&\\(#\\([0-9]+\\)\\|\\([A-Za-z]+\\)\\);" + encoded-str cursor)) + (when (> found-at cursor) + (list-push (substring encoded-str cursor found-at) result)) + (let ((number-entity (match-string-no-properties 2 encoded-str)) + (letter-entity (match-string-no-properties 3 encoded-str))) + (cond (number-entity + (list-push + (char-to-string + (identica-ucs-to-char + (string-to-number number-entity))) result)) + (letter-entity + (cond ((string= "gt" letter-entity) (list-push ">" result)) + ((string= "lt" letter-entity) (list-push "<" result)) + (t (list-push "?" result)))) + (t (list-push "?" result))) + (setq cursor (match-end 0)))) + (list-push (substring encoded-str cursor) result) + (apply 'concat (nreverse result))) + "")) + +(defun identica-timer-action (func) + (let ((buf (get-buffer identica-buffer))) + (if (null buf) + (identica-stop) + (funcall func)))) + +(defun identica-update-status-if-not-blank (method-class method status &optional parameters reply-to-id) + (if (string-match "^\\s-*\\(?:@[-_a-z0-9]+\\)?\\s-*$" status) + nil + (if (equal method-class "statuses") + (identica-http-post method-class method + `(("status" . ,status) + ("source" . ,identica-source) + ,@(if reply-to-id + `(("in_reply_to_status_id" + . ,(number-to-string reply-to-id)))))) + (identica-http-post method-class method + `(("text" . ,status) + ("user" . ,parameters) ;must change this to parse parameters as list + ("source" . ,identica-source)))) + + t)) + +(defvar identica-update-status-edit-map + (let ((map (make-sparse-keymap))) + (define-key map (kbd "C-c C-c") 'identica-update-status-from-edit-buffer-send) + (define-key map (kbd "C-c C-k") 'identica-update-status-from-edit-buffer-cancel) + map)) + +(define-derived-mode identica-update-status-edit-mode text-mode "Identica Status Edit" + (use-local-map identica-update-status-edit-map)) + +(defvar identica-update-status-edit-method-class) +(defvar identica-update-status-edit-method) +(defvar identica-update-status-edit-parameters) +(defvar identica-update-status-edit-reply-to-id) + +(defun identica-update-status-edit-in-edit-buffer (init-str msgtype method-class method parameters &optional reply-to-id) + (let ((buf (get-buffer-create "*identica-status-update-edit*"))) + (pop-to-buffer buf) + (with-current-buffer buf + (if (not (equal major-mode 'identica-update-status-edit-mode)) + (progn + (identica-update-status-edit-mode) + (longlines-mode) + (make-local-variable 'identica-update-status-edit-method-class) + (make-local-variable 'identica-update-status-edit-method) + (make-local-variable 'identica-update-status-edit-parameters) + (make-local-variable 'identica-update-status-edit-reply-to-id) + (if (> (length parameters) 0) + (setq mode-line-format + (cons (format "%s(%s) (%%i/140) " msgtype parameters) + mode-line-format)) + t (setq mode-line-format + (cons (format "%s (%%i/140) " msgtype) mode-line-format))))) + (setq identica-update-status-edit-method-class method-class) + (setq identica-update-status-edit-method method) + (setq identica-update-status-edit-parameters parameters) + (setq identica-update-status-edit-reply-to-id reply-to-id) + (message identica-update-status-edit-method-class) + (insert init-str) + (message "Type C-c C-c to post status update (C-c C-k to cancel).")))) + +(defun identica-show-minibuffer-length (&optional beg end len) + "Show the number of characters in minibuffer." + (when (minibuffer-window-active-p (selected-window)) + (let* ((status-len (- (buffer-size) (minibuffer-prompt-width))) + (mes (format "%d" status-len))) + (if (<= 23 emacs-major-version) + (minibuffer-message mes) ; Emacs23 or later + (minibuffer-message (concat " (" mes ")"))) + ))) + +(defun identica-setup-minibuffer () + (identica-show-minibuffer-length) + (add-hook 'post-command-hook 'identica-show-minibuffer-length t t)) + +(defun identica-finish-minibuffer () + (remove-hook 'post-command-hook 'identica-show-minibuffer-length t)) + +(defun identica-update-status (update-input-method &optional init-str reply-to-id method-class method parameters) + (if (null init-str) (setq init-str "")) + (let ((msgtype "") + (status init-str) + (not-posted-p t) + (user nil) + (map minibuffer-local-map) + (minibuffer-message-timeout nil)) + (define-key map (kbd "<f4>") 'identica-shortenurl-replace-at-point) + (if (null method-class) + (progn (setq msgtype "Status") + (setq method-class "statuses") + (setq method "update")) + (progn (setq msgtype "Direct message") + (setq method-class "direct_messages") + (setq parameters (read-from-minibuffer "To user: " user nil nil nil nil t)) + (setq method "new"))) + (cond ((eq update-input-method 'minibuffer) + (add-hook 'minibuffer-setup-hook 'identica-setup-minibuffer t) + (add-hook 'minibuffer-exit-hook 'identica-finish-minibuffer t) + (unwind-protect + (while not-posted-p + (setq status (read-from-minibuffer (concat msgtype ": ") status nil nil nil nil t)) + (while (< 141 (length status)) + (setq status (read-from-minibuffer (format (concat msgtype "(%d): ") + (- 140 (length status))) + status nil nil nil nil t))) + (setq not-posted-p + (not (identica-update-status-if-not-blank method-class method status parameters reply-to-id)))) + (remove-hook 'minibuffer-setup-hook 'identica-setup-minibuffer) + (remove-hook 'minibuffer-exit-hook 'identica-finish-minibuffer))) + ((eq update-input-method 'edit-buffer) + (identica-update-status-edit-in-edit-buffer init-str msgtype method-class method parameters reply-to-id)) + (t (error "Unknown update-input-method in identica-update-status: %S" update-input-method))))) + +(defun identica-update-status-from-edit-buffer-send () + (interactive) + (with-current-buffer "*identica-status-update-edit*" + (longlines-encode-region (point-min) (point-max)) + (let* ((status (buffer-substring-no-properties (point-min) (point-max))) + (status-len (length status))) + (if (< 140 status-len) + (message (format "Beyond 140 chars. Remove %d chars." (- status-len 140))) + (if (identica-update-status-if-not-blank identica-update-status-edit-method-class + identica-update-status-edit-method status identica-update-status-edit-parameters identica-update-status-edit-reply-to-id) + (progn + (erase-buffer) + (bury-buffer)) + (message "Update failed!")))))) + +(defun identica-update-status-from-minibuffer (&optional init-str method-class method parameters reply-to-id) + (interactive) + (identica-update-status 'minibuffer init-str method-class method parameters reply-to-id)) + +(defun identica-update-status-from-edit-buffer (&optional init-str method-class method parameters) + (interactive) + (identica-update-status 'edit-buffer init-str method-class method parameters)) + +(defun identica-update-status-from-edit-buffer-cancel () + (interactive) + (when (or (not identica-update-status-edit-confirm-cancellation) + (yes-or-no-p + "Really cancel editing this status message (any changes will be lost)?")) + (erase-buffer) + (bury-buffer))) + +(defun identica-update-status-from-region (beg end) + (interactive "r") + (if (> (- end beg) 140) (setq end (+ beg 140))) + (if (< (- end beg) -140) (setq beg (+ end 140))) + (identica-update-status-if-not-blank "statuses" "update" (buffer-substring beg end))) + +(defun identica-tinyurl-unjson-google (result) + "Gets only the URL from JSON URL tinyfying service results. + +Google's shortening service, goo.gl, returns shortened URLs as a +JSON dictionary. This function retrieves only the URL value from +this dictionary, only if identica-urlshortening-service is 'google. +" + (if (eq identica-urlshortening-service 'google) + (cdr (assoc 'short_url (json-read-from-string result))) + result)) + +(defun identica-ur1ca-get (api longurl) + "Shortens url through ur1.ca free service 'as in freedom'" + (let* ((url-request-method "POST") + (url-request-extra-headers + '(("Content-Type" . "application/x-www-form-urlencoded"))) + (url-request-data (concat "longurl=" (url-hexify-string longurl))) + (buffer (url-retrieve-synchronously api))) + (with-current-buffer buffer + (goto-char (point-min)) + (prog1 + (setq ur1short + (if (search-forward-regexp "Your .* is: .*>\\(http://ur1.ca/[0-9A-Za-z].*\\)</a>" nil t) + (match-string-no-properties 1) + (error "URL shortening service failed: %s" longurl))) + (kill-buffer buffer))))) + +(defun identica-shortenurl-get (longurl) + "Shortens url through a url shortening service" + (let ((api (cdr (assoc identica-urlshortening-service + identica-urlshortening-services-map)))) + (unless api + (error "`identica-urlshortening-service' was invalid. try one of %s" + (mapconcat (lambda (x) + (symbol-name (car x))) + identica-urlshortening-services-map ", ") + ".")) + (if longurl + (if (or (eq identica-urlshortening-service 'ur1ca) (eq identica-urlshortening-service 'tighturl)) + (identica-ur1ca-get api longurl) + (let ((buffer (url-retrieve-synchronously (concat api longurl)))) + (with-current-buffer buffer + (goto-char (point-min)) + (prog1 + (identica-tinyurl-unjson-google + (if (search-forward-regexp "\n\r?\n\\([^\n\r]*\\)" nil t) + (match-string-no-properties 1) + (error "URL shortening service failed: %s" longurl))) + (kill-buffer buffer)))) + nil)))) + +(defun identica-shortenurl-replace-at-point () + "Replace the url at point with a tiny version." + (interactive) + (let ((url-bounds (bounds-of-thing-at-point 'url))) + (when url-bounds + (let ((url (identica-shortenurl-get (thing-at-point 'url)))) + (when url + (save-restriction + (narrow-to-region (car url-bounds) (cdr url-bounds)) + (delete-region (point-min) (point-max)) + (insert url))))))) +;;; +;;; Commands +;;; + +(defun identica-start (&optional action) + (interactive) + (if (null action) + (setq action #'identica-current-timeline)) + (if identica-timer + nil + (setq identica-timer + (run-at-time "0 sec" + identica-timer-interval + #'identica-timer-action action))) + (setq identica-active-mode t) + (identica-update-mode-line)) + +(defun identica-stop () +"Stop Current network activitiy (if any) and the reload-timer." + (interactive) + (when (get-buffer-process identica-http-buffer) + (delete-process identica-http-buffer) + (kill-buffer identica-http-buffer)) + (setq identica-method identica-last-timeline-retrieved) + (identica-set-mode-string nil) + (and identica-timer + (cancel-timer identica-timer)) + (setq identica-timer nil) + (setq identica-active-mode nil) + (identica-update-mode-line)) + +(defun identica-get-timeline () + (if (not (eq identica-last-timeline-retrieved identica-method)) + (setq identica-timeline-last-update nil + identica-timeline-data nil)) + (let ((buf (get-buffer identica-buffer))) + (if (not buf) + (identica-stop) + (identica-http-get identica-method-class identica-method))) + (if identica-icon-mode + (if (and identica-image-stack window-system) + (let ((proc + (apply + #'start-process + "wget-images" + nil + "wget" + (format "--directory-prefix=%s" identica-tmp-dir) + "--no-clobber" + "--quiet" + identica-image-stack))) + (set-process-sentinel + proc + (lambda (proc stat) + (clear-image-cache) + )))))) + +(defun identica-friends-timeline () + (interactive) + (setq identica-method "friends_timeline") + (setq identica-method-class "statuses") + (identica-get-timeline)) + +(defun identica-replies-timeline () + (interactive) + (setq identica-method "replies") + (setq identica-method-class "statuses") + (identica-get-timeline)) + +;; (defun identica-direct-messages-timeline () +;; (interactive) +;; (setq identica-method "direct_messages") +;; (setq identica-method-class "none") +;; (identica-get-timeline)) + +(defun identica-public-timeline () + (interactive) + (setq identica-method "public_timeline") + (setq identica-method-class "statuses") + (identica-get-timeline)) + +(defun identica-group-timeline (&optional group) + (interactive) + (unless group + (setq group (read-from-minibuffer "Group: " nil nil nil nil nil t))) + (setq identica-method-class "statusnet/groups") + (if (string-equal group "") + (setq identica-method "timeline") + (setq identica-method (concat "timeline/" group))) + (identica-get-timeline)) + +(defun identica-tag-timeline (&optional tag) + (interactive) + (unless tag + (setq tag (read-from-minibuffer "Tag: " nil nil nil nil nil t))) + (setq identica-method-class "statusnet/tags") + (if (string-equal tag "") + (setq identica-method "timeline") + (setq identica-method (concat "timeline/" tag))) + (identica-get-timeline)) + +(defun identica-user-timeline () + (interactive) + (let ((from-user (read-from-minibuffer "User [Empty for mine]: " + nil nil nil nil nil t))) + (if (string-equal from-user "") + (setq identica-method "user_timeline") + (setq identica-method (concat "user_timeline/" from-user)))) + (identica-get-timeline)) + +(defun identica-current-timeline () + (interactive) + (identica-get-timeline)) + +(defun identica-update-status-interactive () + (interactive) + (identica-update-status identica-update-status-method)) + +(defun identica-direct-message-interactive () + (interactive) + (identica-update-status identica-update-status-method nil nil "direct_messages" "new")) + +(defun identica-erase-old-statuses () + (interactive) + (setq identica-timeline-data nil) + (if (not identica-last-timeline-retrieved) + (setq identica-last-timeline-retrieved identica-method)) + (identica-http-get "statuses" identica-last-timeline-retrieved) + ) + +(defun identica-click () + (interactive) + (let ((uri (get-text-property (point) 'uri))) + (if uri + (browse-url uri)))) + +(defun identica-enter () + (interactive) + (let ((username (get-text-property (point) 'username)) + (id (get-text-property (point) 'id)) + (uri (get-text-property (point) 'uri)) + (group (get-text-property (point) 'group)) + (tag (get-text-property (point) 'tag))) + (if group (identica-group-timeline group) + (if tag (identica-tag-timeline tag) + (if uri (browse-url uri) + (if username + (identica-update-status identica-update-status-method + (concat "@" username " ") id))))))) + +(defun identica-next-link nil + (interactive) + (goto-char (next-single-property-change (point) 'uri)) + (if (not (get-text-property (point) 'uri)) + (goto-char (next-single-property-change (point) 'uri)))) + +(defun identica-prev-link nil + (interactive) + (goto-char (previous-single-property-change (point) 'uri)) + (if (not (get-text-property (point) 'uri)) + (goto-char (previous-single-property-change (point) 'uri)))) + +(defun identica-follow (&optional remove) + (interactive) + (let ((username (get-text-property (point) 'username)) + (method (if remove "destroy" "create")) + (message (if remove "unfollowing" "following"))) + (unless username + (setq username (read-from-minibuffer "user: "))) + (if (> (length username) 0) + (when (y-or-n-p (format "%s %s? " message username)) + (identica-http-post (format "friendships/%s" method) username) + (message (format "Now %s %s" message username))) + (message "No user selected")))) + +(defun identica-unfollow () + (interactive) + (identica-follow t)) + +(defun identica-favorite () + (interactive) + (if (y-or-n-p "Do you want to favor this notice? ") + (let ((id (get-text-property (point) 'id))) + (identica-http-post "favorites/create" (number-to-string id)) + (message "Notice saved as favorite")))) + +(defun identica-repeat () + (interactive) + (if (y-or-n-p "Do you want to repeat this notice? ") + (let ((id (get-text-property (point) 'id))) + (identica-http-post "statuses/retweet" (number-to-string id)) + (message "Notice repeated")))) + +(defun identica-view-user-page () + (interactive) + (let ((uri (get-text-property (point) 'uri))) + (if uri + (browse-url uri)))) + +(defun identica-redent () + (interactive) + (let ((username (get-text-property (point) 'username)) + (id (get-text-property (point) 'id)) + (text (replace-regexp-in-string "!\\(.\\)" "#\\1" (get-text-property (point) 'text)))) + (when username + (identica-update-status identica-update-status-method + (concat identica-redent-format " @" username ": " text) id)))) + +(defun identica-reply-to-user () + (interactive) + (let ((username (get-text-property (point) 'username)) + (id (get-text-property (point) 'id))) + (if username + (identica-update-status identica-update-status-method (concat "@" username " ") id)))) + +(defun identica-get-password () + (or identica-password + (setq identica-password (read-passwd "password: ")))) + +(defun identica-goto-next-status () + "Go to next status." + (interactive) + (let ((pos)) + (setq pos (identica-get-next-username-face-pos (point))) + (if pos + (goto-char pos) + (message "End of status.")))) + +(defun identica-get-next-username-face-pos (pos) + (interactive) + (let ((prop)) + (catch 'not-found + (while (and pos (not (eq prop identica-username-face))) + (setq pos (next-single-property-change pos 'face)) + (when (eq pos nil) (throw 'not-found nil)) + (setq prop (get-text-property pos 'face))) + pos))) + +(defun identica-goto-previous-status () + "Go to previous status." + (interactive) + (let ((pos)) + (setq pos (identica-get-previous-username-face-pos (point))) + (if pos + (goto-char pos) + (message "Start of status.")))) + +(defun identica-get-previous-username-face-pos (pos) + (interactive) + (let ((prop)) + (catch 'not-found + (while (and pos (not (eq prop identica-username-face))) + (setq pos (previous-single-property-change pos 'face)) + (when (eq pos nil) (throw 'not-found nil)) + (setq prop (get-text-property pos 'face))) + pos))) + +(defun identica-goto-next-status-of-user () + "Go to next status of user." + (interactive) + (let ((user-name (identica-get-username-at-pos (point))) + (pos (identica-get-next-username-face-pos (point)))) + (while (and (not (eq pos nil)) + (not (equal (identica-get-username-at-pos pos) user-name))) + (setq pos (identica-get-next-username-face-pos pos))) + (if pos + (goto-char pos) + (if user-name + (message "End of %s's status." user-name) + (message "Invalid user-name."))))) + +(defun identica-goto-previous-status-of-user () + "Go to previous status of user." + (interactive) + (let ((user-name (identica-get-username-at-pos (point))) + (pos (identica-get-previous-username-face-pos (point)))) + (while (and (not (eq pos nil)) + (not (equal (identica-get-username-at-pos pos) user-name))) + (setq pos (identica-get-previous-username-face-pos pos))) + (if pos + (goto-char pos) + (if user-name + (message "Start of %s's status." user-name) + (message "Invalid user-name."))))) + +(defun identica-get-username-at-pos (pos) + (let ((start-pos pos) + (end-pos)) + (catch 'not-found + (while (eq (get-text-property start-pos 'face) identica-username-face) + (setq start-pos (1- start-pos)) + (when (or (eq start-pos nil) (eq start-pos 0)) (throw 'not-found nil))) + (setq start-pos (1+ start-pos)) + (setq end-pos (next-single-property-change pos 'face)) + (buffer-substring start-pos end-pos)))) + +(defun identica-get-status-url (id) + "Generate status URL." + (format "https://%s/notice/%s" statusnet-server id)) + +(defun identica-get-context-url (id) + "Generate status URL." + (format "https://%s/conversation/%s" statusnet-server id)) + +;; Icons +;;; ACTIVE/INACTIVE +(defconst identica-active-indicator-image + (when (image-type-available-p 'xpm) + '(image :type xpm + :ascent center + :data + "/* XPM */ +static char * statusnet_xpm[] = { +\"16 16 14 1\", +\" c None\", +\". c #8F0000\", +\"+ c #AB4040\", +\"@ c #D59F9F\", +\"# c #E3BFBF\", +\"$ c #CE8F8F\", +\"% c #C78080\", +\"& c #FFFFFF\", +\"* c #B96060\", +\"= c #DCAFAF\", +\"- c #C07070\", +\"; c #F1DFDF\", +\"> c #961010\", +\", c #9D2020\", +\" ....... \", +\" ......... \", +\" ........... \", +\" ....+@#$+.... \", +\"....%&&&&&*.... \", +\"...+&&&&&&&+... \", +\"...=&&&&&&&$... \", +\"...#&&&&&&&#... \", +\"...=&&&&&&&@... \", +\"...*&&&&&&&-... \", +\"....@&&&&&&=... \", +\" ....-#&#$;&>.. \", +\" ..........,>.. \", +\" ............. \", +\" ............\", +\" . ..\"};"))) + +(defconst identica-inactive-indicator-image + (when (image-type-available-p 'xpm) + '(image :type xpm + :ascent center + :data + "/* XPM */ +static char * statusnet_off_xpm[] = { +\"16 16 13 1\", +\" g None\", +\". g #5B5B5B\", +\"+ g #8D8D8D\", +\"@ g #D6D6D6\", +\"# g #EFEFEF\", +\"$ g #C9C9C9\", +\"% g #BEBEBE\", +\"& g #FFFFFF\", +\"* g #A5A5A5\", +\"= g #E3E3E3\", +\"- g #B2B2B2\", +\"; g #676767\", +\"> g #747474\", +\" ....... \", +\" ......... \", +\" ........... \", +\" ....+@#$+.... \", +\"....%&&&&&*.... \", +\"...+&&&&&&&+... \", +\"...=&&&&&&&$... \", +\"...#&&&&&&&#... \", +\"...=&&&&&&&@... \", +\"...*&&&&&&&-... \", +\"....@&&&&&&=... \", +\" ....-#&#$&&;.. \", +\" ..........>;.. \", +\" ............. \", +\" ............\", +\" . ..\"};"))) + +(let ((props + (when (display-mouse-p) + `(local-map + ,(purecopy (make-mode-line-mouse-map + 'mouse-2 #'identica-toggle-activate-buffer)) + help-echo "mouse-2 toggles automatic updates")))) + (defconst identica-modeline-active + (if identica-active-indicator-image + (apply 'propertize " " + `(display ,identica-active-indicator-image ,@props)) + " ")) + (defconst identica-modeline-inactive + (if identica-inactive-indicator-image + (apply 'propertize "INACTIVE" + `(display ,identica-inactive-indicator-image ,@props)) + "INACTIVE"))) + + (make-local-variable 'identica-active-mode) + (setq identica-active-mode t) + +(defun identica-toggle-activate-buffer () + (interactive) + (setq identica-active-mode (not identica-active-mode)) + (if (not identica-active-mode) + (identica-stop) + (identica-start))) + +(defun identica-mode-line-buffer-identification () + (if identica-active-mode + identica-modeline-active + identica-modeline-inactive)) + +(defun identica-update-mode-line () + "Update mode line." + (force-mode-line-update)) + +;;;###autoload +(defun identica () + "Start identica-mode." + (interactive) + (identica-mode)) + +(provide 'identica-mode) +;;; identica.el ends here |