From mboxrd@z Thu Jan 1 00:00:00 1970 From: SAKURAI Masashi Subject: Re: [calfw] Better use of space Date: Mon, 25 Jul 2011 12:41:44 +0900 Message-ID: <20110725034144.4073713C51B@vps1.kiwanami.net> References: <87tyag57ue.fsf@gmail.com> <20110722070359.2BC7F13C54E@vps1.kiwanami.net> <87hb6e7k6p.fsf@gmail.com> Mime-Version: 1.0 (generated by SEMI 1.14.6 - "Maruoka") Content-Type: text/plain; charset=ISO-2022-JP Return-path: Received: from eggs.gnu.org ([140.186.70.92]:52066) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QlC3D-0002UF-Kx for emacs-orgmode@gnu.org; Sun, 24 Jul 2011 23:41:52 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1QlC3C-0002Ly-Cg for emacs-orgmode@gnu.org; Sun, 24 Jul 2011 23:41:51 -0400 Received: from vps1.kiwanami.net ([182.48.41.71]:15896) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QlC3B-0002LT-UR for emacs-orgmode@gnu.org; Sun, 24 Jul 2011 23:41:50 -0400 In-Reply-To: <87hb6e7k6p.fsf@gmail.com> List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: rasmus@gmx.us Cc: emacs-orgmode@gnu.org Hi Rasmus, At Fri, 22 Jul 2011 11:12:46 +0200, Rasmus wrote: > : > > * Display multiple-lines items (the source splits an item multiple lines.) > > > > This is not so difficult. In this mechanism, the source objects can > > propose some formats, for example, "15:00 appointment" and ("15:00-15:30" > > "appointment"). Then, calfw chooses the suitable format and displays > > in the current layout algorithm. > > It could be a string similar to how BBDB, Gnus and other Emacs mode does > it. See for example (describe-variable 'gnus-summary-line-format). > > User could specify calfw:timeview-format "%Starttime-%Endtime: %Event" > or whatever. Thanks for references. I will check them. > > * Word-wrapping and folding lines (calfw splits lines within a column.) > > > > This is little difficult. I think word-wrapping, folding lines and > > truncating strings can not be achieved in the narrow columns > > straightforwardly. I need a time to study this issue. > > Hmm, > I guess the width of column is calculated when generating the view. > I'll use pseudo-code as my Emacs Lisp isn't great. > #+begin_src emacs-lisp > (if (> (calfw:timeview-entry-length) (calfw:column-length)) > (#split-entry after column-length, preferbly after word > # and retur > ) > #+end_src > I hope it makes sense. . . Yes. The code is the start point. I would discuss how to split a line. I show two simple code as following: (Note: These codes include Japanese characters.) * Simple counting and splitting This code splits words mechanically. I think it is bad for the Western languages. However, for the Eastern Asian languages, this result is not bad. #+begin_src emacs-lisp (let ((str "The quick brown fox jumped over the lazy dog. The internationalization and Localization are long words. 日本語を含むときの場合。") (fill-column 10)) (loop with ret = nil with curcol = 0 with lastpos = 0 with endpos = (1- (length str)) for i from 0 upto endpos for c = (aref str i) for w = (char-width c) if (or (= endpos i) (<= fill-column (+ curcol w))) do (push (substring str lastpos (1+ i)) ret) (setq lastpos (1+ i) curcol 0) else do (incf curcol w) finally return (mapconcat 'identity (nreverse ret) "\n"))) ; => "The quick brown fox jumped ove r the lazy dog. The internatio nalization and Local ization ar e long wor ds. 日本語 を含むとき の場合。" #+end_src * Word-wrapping by fill function of Emacs This splitting is smarter, but not perfect. Long words are still need truncation or hyphenation. #+begin_src emacs-lisp (let ((str "The quick brown fox jumped over the lazy dog. The internationalization and Localization are long words. 日本語を含むときの場合。") (fill-column 10)) (with-temp-buffer (insert str) (fill-region (point-min) (point-max)) (buffer-string))) ; => "The quick brown fox jumped over the lazy dog. The internationalization and Localization are long words. 日本 語を含むと きの場合。" #+end_src So, I think I should study the word-wrapping algorithm. If someone knows better algorithm or implementations, please let me know. Regards, -- SAKURAI, Masashi (family, given) m.sakurai@kiwanami.net