emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: SAKURAI Masashi <m.sakurai@kiwanami.net>
To: rasmus@gmx.us
Cc: emacs-orgmode@gnu.org
Subject: Re: [calfw] Better use of space
Date: Mon, 25 Jul 2011 12:41:44 +0900	[thread overview]
Message-ID: <20110725034144.4073713C51B@vps1.kiwanami.net> (raw)
In-Reply-To: <87hb6e7k6p.fsf@gmail.com>

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

  reply	other threads:[~2011-07-25  3:41 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-07-21  8:57 [calfw] Better use of space Rasmus
2011-07-22  7:03 ` SAKURAI Masashi
2011-07-22  9:12   ` Rasmus
2011-07-25  3:41     ` SAKURAI Masashi [this message]
2011-09-06  2:11       ` SAKURAI Masashi
2011-09-07  8:32         ` Rasmus
2011-09-08  1:50           ` SAKURAI Masashi

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20110725034144.4073713C51B@vps1.kiwanami.net \
    --to=m.sakurai@kiwanami.net \
    --cc=emacs-orgmode@gnu.org \
    --cc=rasmus@gmx.us \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).