kiwanami / emacs-calfw

A calendar framework for Emacs
1.15k stars 96 forks source link

Calendar tables get confused by inline images (display text properties) #1

Open tsdh opened 13 years ago

tsdh commented 13 years ago

I've just discovered calfw and it's awesome! I use it together with org-mode.

One minor glitch is that the tables get confused by images. For example, in one of my org files I have this entry:

* Wetter                                                            :weather:
** Montabaur
   :PROPERTIES:
   :CATEGORY: Montabaur 
   :LOCATION: Montabaur, Germany
   :END:
%%(org-google-weather "Montabaur" "de")

This uses the org-google-weather package to insert a short weather forecast including an icon (sunny, cloudy, etc.) into the org agenda buffer.

Screenshot Org Agenda: http://dl.dropbox.com/u/30611246/img/org-agenda.png

When that is converted to a calfw calendar table, then the borders of the cells are wrong.

Screenshot Calfw: http://dl.dropbox.com/u/30611246/img/org-calfw.png

Clearly, the table code relies on monospaced fonts and images don't fit well here. So I think you should just strip images, that is, the display text property.

This is a very simply patch that fixes the issue for me:

diff --git a/calfw-org.el b/calfw-org.el
index 99fe18e..5dcdc17 100644
--- a/calfw-org.el
+++ b/calfw-org.el
@@ -69,7 +69,10 @@
          (buffer (marker-buffer marker)))
     (propertize
      (concat item " " (buffer-name buffer))
-     'keymap cfw:org-text-keymap)))
+     'keymap cfw:org-text-keymap
+     ;; Delete the display property, since displaying images will break our
+     ;; table layout.
+     'display nil)))

 (defvar cfw:org-schedule-summary-transformer 'cfw:org-summary-format
   "Transformation function which transforms the org item string to calendar title.

However, I'm not convinced that it is a good idea to only fix the org mode stuff. Most probably the filtering (or better, a nifty implementation of how to correctly handle display specs) of display text properties should be in calfw.el, but I can't spot the right location at a first glance.

kiwanami commented 13 years ago

Thank you for your comment and bug report.

Yes, I also think that calfw should display images in the grids. So, I will try org-google-weather to research using images in org files. Please give me a time to research.

If it takes much time for me to implement the function, I would merge your patch to the master branch to avoid the problem.

tsdh commented 13 years ago

Hi!

Yes, I also think that calfw should display images in the grids. So, I will try org-google-weather to research using images in org files. Please give me a time to research.

Sure. By the way, I just noticed that besides images also unicode characters skrew the table layout. Again as an example, org-google-weather inserts a ℃ character which is slightly wider than normal ascii chars, at least with the font emacs chooses to display it. (I use DeJaVu Sans Mono by default, but that doesn't contain this character, and so emacs falls back to xft:-unknown-AntPoltSemiCond.)

If it takes much time for me to implement the function, I would merge your patch to the master branch to avoid the problem.

Feel free to do so. But as I've said, I think a proper handling of display text properties (even if it's simply removing them) belongs into calfw.el instead of only the org mode backend.

Bye, Tassilo