Valkertown Blog

I used to write about electronics…

Valkertown Blog header image 2

Emacs Denting mode for laconicas (including identi.ca)

February 16th, 2009 by Carlos Perilla

Denting Mode

I guess one of the main advantages that laconica has is being twitter compatible because if you have the source you can get a twitter only app to work on any laconica instance, so I found the twittering mode for emacs here:
http://lambdarepos.svnrepository.com/share/trac.cgi/browser/lang/elisp/twittering-mode

Then I decided to port it to laconica so I could use it to post to Brainbird, which is my own laconica instance.

I added the denting group for customization and I would like to use a password system like the one that weblogger.el uses. Now you can set the laconica instance you want to use by setting the laconica-instance variable.

The bindigns as always with emacs modes are the most sexy part, so here they are. I added none Im just posting this to make it easier for the interested to get to know which they are.

  1.      (define-key km "\C-c\C-f" denting-friends-timeline)
  2.       (define-key km "\C-c\C-s" denting-update-status-interactive)
  3.       (define-key km "\C-c\C-e" denting-erase-old-statuses)
  4.       (define-key km "\C-m" denting-enter)
  5.       (define-key km "\C-c\C-l" denting-update-lambda)
  6.       (define-key km [mouse-1] denting-click)
  7.       (define-key km "\C-c\C-v" denting-view-user-page)
  8.       ;; (define-key km "j" next-line)
  9.       ;; (define-key km "k" previous-line)
  10.       (define-key km "j" denting-goto-next-status)
  11.       (define-key km "k" denting-goto-previous-status)
  12.       (define-key km "l" forward-char)
  13.       (define-key km "h" backward-char)
  14.       (define-key km "0" beginning-of-line)
  15.       (define-key km "^" beginning-of-line-text)
  16.       (define-key km "$" end-of-line)
  17.       (define-key km "n" denting-goto-next-status-of-user)
  18.       (define-key km "p" denting-goto-previous-status-of-user)
  19.       (define-key km [backspace] backward-char)
  20.       (define-key km "G" end-of-buffer)
  21.       (define-key km "H" beginning-of-buffer)
  22.       (define-key km "i" denting-icon-mode)
  23.       (define-key km "s" denting-scroll-mode)
  24.       (define-key km "t" denting-toggle-proxy)
  25.       (define-key km "\C-c\C-p" denting-toggle-proxy)

The icon mode is nice, since it displays in recent emacs the avatars ofthe laconicats youre following. You can download the denting-mode.el here:

http://hg.valkertown.org/denting-mode.hg

If you hit one of the many bugs this code might have, please comment here and I might try to solve it. But bear with me Im not an usual emacs lisp programmer and this quialifies more to a hack than a proper release.

Tags: Comments

  • hey, I just found out about denting-mode. I made my own port of twittering-mode called identica-mode a few months ago http://blog.nethazard.net/identica-mode-for-emacs I've added support for tags and groups and a global posting shortcut, maybe you can find it useful.

    I'm having the same trouble with the xml parsing thing. Have you been able to fix it? The problem is that when it fetches the feed, the xml has some weird char codes inside the xml tag, thus breaking the parsing. I reported this behavior to laconica developers, but they claim their feed is okay. Twitter's feed has no problems though.
  • Hello, I had the very same problem but Christian Cheng sent me a patch which solves the issue. I did my work without proper search first so I duplicated a lot of your efforts and I did a merge with your code few days ago so denting-mode has most of the features you did implement. I don't know if you updated the code recently but I will check again the diffs to merge your work in.
  • Yes I have the same problem, it's a bit annoying but totally harmless, it's just the xml parser failing from time to time to parse the laconica response. For a quick fix I only can think about shutting the hell out of it by capturing the error. On the proper way to solve the problem, it would require to figure out why the twitter/identica serves bad xml and correct it. My bets are on the api limit(so maybe just setting up the update interval to a larger number might fix it)

    Also you can avoid the wrapper function by using the identi.cas twitter bridge on your account settings. If you really want that function I think it would be something like this:

    (defun multi-update-status-from-minibuffer (&optional init-str)
    (if (null init-str) (setq init-str ""))
    (let ((status init-str))
    (setq status (read-from-minibuffer "status: " status nil nil nil nil t))
    (denting-update-status-if-not-blank status)
    (twittering-update-status-if-not-blank status)))
  • titaniumbones
    hey deepspawn, what do you mean by "shutting the hell out of it by capturing the error" -- sorry, not really a coder, don't quite get what you mean.
    not sure it'sthe api limit since it now seems to come up every time, not just occasionally. though now i think of it, gwibber was up on this machine as well, will shut it down and try in a few minutes.

    my wrapper funciton looks a lot like the one you built, though yours is a little bit better. thanks! -- matt
  • Sorry for taking so long, well It's not so hard

    line 661 of current denting-mode.el

    648 (defun denting-http-post-default-sentinel (proc stat &optional suc-msg)
    649
    650 (condition-case err-signal
    651 (let ((header (denting-get-response-header))
    652 ;; (body (denting-get-response-body)) not used now.
    653 (status nil))
    654 (string-match "HTTP/1\.1 \\([a-z0-9 ]+\\)\r?\n" header)
    655 (setq status (match-string-no-properties 1 header))
    656 (case-string status
    657 (("200 OK")
    658 (message (if suc-msg suc-msg "Success: Post")))
    659 (t (message status)))
    660 )
    661 (error (message (prin1-to-string err-signal))))
    662 )

    You can replace it with:

    (error (message "Failed")))

    You will replace the annoying message for a brief "Failed" message, it will not solve the issue but at least will not bug you with the full error. I will keep the full error printing for now, since maybe I can do a proper fix of the problem.
  • Hi,

    thanks for this! it's great to have a denting mode. at first it worked great for me, but for some reaosn now i keep getting an xml error that i don't understand at all. I tried twittering mode and do not get a similar error with them. Here's the backtrace:

    Debugger entered--Lisp error: (error "XML: (Not Well-Formed) Invalid end tag (expecting in_reply_to_user_id) at pos 8365")
    signal(error ("XML: (Not Well-Formed) Invalid end tag (expecting in_reply_to_user_id) at pos 8365"))
    error("XML: (Not Well-Formed) Invalid end tag (expecting %s) at pos %d" "in_reply_to_user_id" 8365)
    xml-parse-tag(nil nil)
    xml-parse-tag(nil nil)
    xml-parse-tag(nil nil)
    xml-parse-tag(nil nil)
    xml-parse-region(350 16256)
    (let ((content ...)) (xml-parse-region (+ ... ...) (point-max)))
    (let ((content ...)) (let (...) (xml-parse-region ... ...)))
    (save-excursion (set-buffer buffer) (let (...) (let ... ...)))
    denting-get-response-body()
    (let ((header ...) (body ...) (status nil)) (if (string-match "HTTP/1.[01] \\([a-z0-9 ]+\\)
    ?\n" header) (progn ... ...) (message "Failure: Bad http response.")))
    denting-http-get-default-sentinel(#<process network-connection-process> "connection broken by remote peer\n")
    recursive-edit()


    do you ever see anything like this, or have any debugging suggestions? i'd just written a wrapper function that double-poststo twitter and identi.ca, so now i'm bummed it's not working! thanks,
    matt
blog comments powered by Disqus