Open bmp opened 7 years ago
Please support this!
@bmp @Mosesofmason I managed to create the following ugly hack. It's ugly, but it works.
Demo:
(defun *twittering-generate-format-table (status-sym prefix-sym)
`(("%" . "%")
("}" . "}")
("#" . (cdr (assq 'id ,status-sym)))
("'" . (when (cdr (assq 'truncated ,status-sym))
"..."))
("c" .
(let ((system-time-locale "C"))
(format-time-string "%a %b %d %H:%M:%S %z %Y"
(cdr (assq 'created-at ,status-sym)))))
("d" . (cdr (assq 'user-description ,status-sym)))
("f" .
(twittering-make-string-with-source-property
(cdr (assq 'source ,status-sym)) ,status-sym))
("i" .
(when (and twittering-icon-mode window-system)
(let ((url
(cond
((and twittering-use-profile-image-api
(eq twittering-service-method 'twitter)
(or (null twittering-convert-fix-size)
(member twittering-convert-fix-size '(48 73))))
(let ((user (cdr (assq 'user-screen-name ,status-sym)))
(size
(if (or (null twittering-convert-fix-size)
(= 48 twittering-convert-fix-size))
"normal"
"bigger")))
(format "http://%s/%s/%s.xml?size=%s" twittering-api-host
(twittering-api-path "users/profile_image") user size)))
(t
(cdr (assq 'user-profile-image-url ,status-sym))))))
(twittering-make-icon-string nil nil url))))
("I" .
(let* ((entities (cdr (assq 'entity ,status-sym)))
text)
(mapc (lambda (url-info)
(setq text (or (cdr (assq 'media-url url-info)) "")))
(cdr (assq 'media entities)))
(if (string-equal "" text)
text
(let ((twittering-convert-fix-size 360))
(twittering-make-icon-string nil nil text)))))
("j" . (cdr (assq 'user-id ,status-sym)))
("L" .
(let ((location (or (cdr (assq 'user-location ,status-sym)) "")))
(unless (string= "" location)
(concat " [" location "]"))))
("l" . (cdr (assq 'user-location ,status-sym)))
("p" . (when (cdr (assq 'user-protected ,status-sym))
"[x]"))
("r" .
(let ((reply-id (or (cdr (assq 'in-reply-to-status-id ,status-sym)) ""))
(reply-name (or (cdr (assq 'in-reply-to-screen-name ,status-sym))
""))
(recipient-screen-name
(cdr (assq 'recipient-screen-name ,status-sym))))
(let* ((pair
(cond
(recipient-screen-name
(cons (format "sent to %s" recipient-screen-name)
(twittering-get-status-url recipient-screen-name)))
((and (not (string= "" reply-id))
(not (string= "" reply-name)))
(cons (format "in reply to %s" reply-name)
(twittering-get-status-url reply-name reply-id)))
(t nil)))
(str (car pair))
(url (cdr pair))
(properties
(list 'mouse-face 'highlight 'face 'twittering-uri-face
'keymap twittering-mode-on-uri-map
'uri url
'front-sticky nil
'rear-nonsticky t)))
(when (and str url)
(concat " " (apply 'propertize str properties))))))
("R" .
(let ((retweeted-by
(or (cdr (assq 'retweeting-user-screen-name ,status-sym)) "")))
(unless (string= "" retweeted-by)
(concat " (retweeted by " retweeted-by ")"))))
("S" .
(twittering-make-string-with-user-name-property
(cdr (assq 'user-name ,status-sym)) ,status-sym))
("s" .
(twittering-make-string-with-user-name-property
(cdr (assq 'user-screen-name ,status-sym)) ,status-sym))
("U" .
(twittering-make-fontified-tweet-unwound ,status-sym))
;; ("D" .
;; (twittering-make-fontified-tweet-unwound ,status-sym))
("T" .
,(twittering-make-fontified-tweet-text
`(twittering-make-fontified-tweet-text-with-entity ,status-sym)
twittering-regexp-hash twittering-regexp-atmark))
("t" .
,(twittering-make-fontified-tweet-text
`(twittering-make-fontified-tweet-text-with-entity ,status-sym)
twittering-regexp-hash twittering-regexp-atmark))
("u" . (cdr (assq 'user-url ,status-sym)))))
(advice-add #'twittering-generate-format-table :override #'*twittering-generate-format-table)
@fuxialexander Could you give me a hint where to put the code, please? I try to put it in the .emacs
file but without luck. Thank you very much!
@Mosesofmason wrap the code in a (with-eval-after-load 'twittering-mode )
block, and tweak the twittering-status-format
to include an %I
entry.
To replicate my setup:
(with-eval-after-load 'twittering-mode
(defun *twittering-generate-format-table (status-sym prefix-sym)
`(("%" . "%")
("}" . "}")
("#" . (cdr (assq 'id ,status-sym)))
("'" . (when (cdr (assq 'truncated ,status-sym))
"..."))
("c" .
(let ((system-time-locale "C"))
(format-time-string "%a %b %d %H:%M:%S %z %Y"
(cdr (assq 'created-at ,status-sym)))))
("d" . (cdr (assq 'user-description ,status-sym)))
("f" .
(twittering-make-string-with-source-property
(cdr (assq 'source ,status-sym)) ,status-sym))
("i" .
(when (and twittering-icon-mode window-system)
(let ((url
(cond
((and twittering-use-profile-image-api
(eq twittering-service-method 'twitter)
(or (null twittering-convert-fix-size)
(member twittering-convert-fix-size '(48 73))))
(let ((user (cdr (assq 'user-screen-name ,status-sym)))
(size
(if (or (null twittering-convert-fix-size)
(= 48 twittering-convert-fix-size))
"normal"
"bigger")))
(format "http://%s/%s/%s.xml?size=%s" twittering-api-host
(twittering-api-path "users/profile_image") user size)))
(t
(cdr (assq 'user-profile-image-url ,status-sym))))))
(twittering-make-icon-string nil nil url))))
("I" .
(let* ((entities (cdr (assq 'entity ,status-sym)))
text)
(mapc (lambda (url-info)
(setq text (or (cdr (assq 'media-url url-info)) "")))
(cdr (assq 'media entities)))
(if (string-equal "" text)
text
(let ((twittering-convert-fix-size 360))
(twittering-make-icon-string nil nil text)))))
("j" . (cdr (assq 'user-id ,status-sym)))
("L" .
(let ((location (or (cdr (assq 'user-location ,status-sym)) "")))
(unless (string= "" location)
(concat " [" location "]"))))
("l" . (cdr (assq 'user-location ,status-sym)))
("p" . (when (cdr (assq 'user-protected ,status-sym))
"[x]"))
("r" .
(let ((reply-id (or (cdr (assq 'in-reply-to-status-id ,status-sym)) ""))
(reply-name (or (cdr (assq 'in-reply-to-screen-name ,status-sym))
""))
(recipient-screen-name
(cdr (assq 'recipient-screen-name ,status-sym))))
(let* ((pair
(cond
(recipient-screen-name
(cons (format "sent to %s" recipient-screen-name)
(twittering-get-status-url recipient-screen-name)))
((and (not (string= "" reply-id))
(not (string= "" reply-name)))
(cons (format "in reply to %s" reply-name)
(twittering-get-status-url reply-name reply-id)))
(t nil)))
(str (car pair))
(url (cdr pair))
(properties
(list 'mouse-face 'highlight 'face 'twittering-uri-face
'keymap twittering-mode-on-uri-map
'uri url
'front-sticky nil
'rear-nonsticky t)))
(when (and str url)
(concat " " (apply 'propertize str properties))))))
("R" .
(let ((retweeted-by
(or (cdr (assq 'retweeting-user-screen-name ,status-sym)) "")))
(unless (string= "" retweeted-by)
(concat " (retweeted by " retweeted-by ")"))))
("S" .
(twittering-make-string-with-user-name-property
(cdr (assq 'user-name ,status-sym)) ,status-sym))
("s" .
(twittering-make-string-with-user-name-property
(cdr (assq 'user-screen-name ,status-sym)) ,status-sym))
("U" .
(twittering-make-fontified-tweet-unwound ,status-sym))
;; ("D" .
;; (twittering-make-fontified-tweet-unwound ,status-sym))
("T" .
,(twittering-make-fontified-tweet-text
`(twittering-make-fontified-tweet-text-with-entity ,status-sym)
twittering-regexp-hash twittering-regexp-atmark))
("t" .
,(twittering-make-fontified-tweet-text
`(twittering-make-fontified-tweet-text-with-entity ,status-sym)
twittering-regexp-hash twittering-regexp-atmark))
("u" . (cdr (assq 'user-url ,status-sym)))))
(advice-add #'twittering-generate-format-table :override #'*twittering-generate-format-table)
(defface twitter-divider
`((t (:underline (:color "grey"))))
"The vertical divider between tweets."
:group 'twittering-mode)
(setq twittering-icon-mode t
twittering-use-icon-storage t
twittering-convert-fix-size 40
twittering-status-format "
%i %FACE[font-lock-function-name-face]{ @%s} %FACE[italic]{%@} %FACE[error]{%FIELD-IF-NONZERO[❤ %d]{favorite_count}} %FACE[warning]{%FIELD-IF-NONZERO[↺ %d]{retweet_count}}
%FOLD[ ]{%FILL{%t}
%QT{
%FOLD[ ]{%FACE[font-lock-function-name-face]{@%s}\t%FACE[shadow]{%@}
%FOLD[ ]{%FILL{%t}}
}}}
%I
%FACE[twitter-divider]{ }
"))
Thanks, it works like a charm.
@fuxialexander, thanks for that, it works but unfortunately for me the images are not sized properly. They seem to be sized at less than the user image.
And with my previous setup it was,
I am using the following to display tweets,
(setq twittering-status-format "%RT{Retweeted by %S %FACE[glyphless-char]{%@}\n%FACE[bold]{RT }}%i %S %FACE[glyphless-char]{@%s tweeted at %@}\n%FOLD[ ]{%T \n%FACE[glyphless-char]{RT %FIELD-IF-NONZERO[%d]{retweet_count} FAV %FIELD-IF-NONZERO[%d]{favorite_count} %f%L%r}%QT{\n+----\n%FOLD[|]{%i %S %FACE[glyphless-char]{@%s tweeted at %@}\n%FOLD[ ]{%T \n%FACE[glyphless-char]{RT %FIELD-IF-NONZERO[%d]{retweet_count} FAV %FIELD-IF-NONZERO[%d]{favorite_count} %f%L%r}}}\n+----}}\n")
@bmp The size is set in this line (twittering-convert-fix-size 360)
which should work. Try execute this function
(defun +twitter/rerender-all ()
(interactive)
(dolist (buf (doom-buffers-in-mode 'twittering-mode (buffer-list)))
(with-current-buffer buf
(twittering-rerender-timeline-all buf t)
(setq-local line-spacing 0.2)
(goto-char (point-min))
)))
to refresh the display. Sometimes I need to do that to make the image show at the right size.
Thanks, that works.
This is such a great feature would love to see it added as a tuneable feature.
Does anyone know if twittering mode allows for images of a tweet can be displayed (Twitter allows us to attach images to a tweet)?
Similar to displaying user icons, if we can display these images.
I've attached a sample of such an image on twitter's interface (image1):
This is how this is rendered on twittering mode based on my customisation file (image 2):