emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Feng Shu <tumashu@gmail.com>
To: orgmode <emacs-orgmode@gnu.org>
Subject: about truncate line depend context
Date: Mon, 24 Mar 2014 22:55:08 +0800	[thread overview]
Message-ID: <87y4zz8x4j.fsf@news.tumashu-localhost.org> (raw)


Now I set  truncate-lines to -1 in my org file, but the table shows
ugly, So I use below code.

Can I use a hook to do this job?

#+begin_src elisp
(defun eh-org-truncate-lines (&optional arg)
  (interactive "P")
  (cond
   ((or (and (boundp 'org-clock-overlays) org-clock-overlays)
	org-occur-highlights
	org-latex-fragment-image-overlays)
    (and (boundp 'org-clock-overlays) (org-clock-remove-overlays))
    (org-remove-occur-highlights)
    (org-remove-latex-fragment-image-overlays)
    (message "Temporary highlights/overlays removed from current buffer"))
   (t
    (let* ((context (org-element-context)) (type (org-element-type context)))
      (case type
	((table table-cell table-row item plain-list)
	 (toggle-truncate-lines 1))
	(t (toggle-truncate-lines -1)))))))

(defun eh-org-ctrl-c-ctrl-c (&optional arg)
  (interactive)
  (eh-org-truncate-lines arg)
  (org-ctrl-c-ctrl-c arg))

(org-defkey org-mode-map "\C-c\C-c" 'eh-org-ctrl-c-ctrl-c)

#+end_src

-- 

                 reply	other threads:[~2014-03-24 15:10 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=87y4zz8x4j.fsf@news.tumashu-localhost.org \
    --to=tumashu@gmail.com \
    --cc=emacs-orgmode@gnu.org \
    /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).