平衡点


2022/02/18

_ ox-beamer の拡張

ox-beamer をちょっと拡張して \institute なんかを使える様にしてみた. 元の関数の深い所を advice で書き換えることを試みるも上手くできなかったので まるっとコピーして処理を追加したり.

(leaf ox-beamer
  :after ox-latex
  :init
  (add-to-list 'org-export-options-alist
               '(:shortdate     "SHORT_DATE"       nil nil))
  (add-to-list 'org-export-options-alist
               '(:shorttitle    "SHORT_TITLE"      nil nil))
  (add-to-list 'org-export-options-alist
               '(:shortauthor   "SHORT_AUTHOR"     nil nil))
  (add-to-list 'org-export-options-alist
               '(:institute      "INSTITUTE"       nil nil))
  (add-to-list 'org-export-options-alist
               '(:shortinstitute "SHORT_INSTITUTE" nil nil))
  (add-to-list 'org-latex-classes
               '("my:beamer"
                 "\\RequirePackage{plautopatch}\n\\documentclass[dvipdfmx,presentation]{beamer}
             [NO-DEFAULT-PACKAGES] [NO-PACKAGES] [EXTRA]"
                 ("\\section\{%s\}" . "\\section*\{%s\}")
                 ("\\subsection\{%s\}" . "\\subsection*\{%s\}")
                 ("\\subsubsection\{%s\}" . "\\subsubsection*\{%s\}")))
  ;; customize
  (defun my:org-beamer-template (contents info)
    "Custom: support shortdate, shorttile, shortauthor, institute for beamer export"
    (let ((title (org-export-data (plist-get info :title) info))
	      (subtitle (org-export-data (plist-get info :subtitle) info)))
      (concat
       ;; Time-stamp.
       (and (plist-get info :time-stamp-file)
	        (format-time-string "%% Created %Y-%m-%d %a %H:%M\n"))
       ;; LaTeX compiler
       (org-latex--insert-compiler info)
       ;; Document class and packages.
       (org-latex-make-preamble info)
       ;; Insert themes.
       (let ((format-theme
	          (lambda (prop command)
	            (let ((theme (plist-get info prop)))
		          (when theme
		            (concat command
			                (if (not (string-match "\\[.*\\]" theme))
			                    (format "{%s}\n" theme)
			                  (format "%s{%s}\n"
				                      (match-string 0 theme)
				                      (org-trim
				                       (replace-match "" nil nil theme))))))))))
         (mapconcat (lambda (args) (apply format-theme args))
		            '((:beamer-theme "\\usetheme")
		              (:beamer-color-theme "\\usecolortheme")
		              (:beamer-font-theme "\\usefonttheme")
		              (:beamer-inner-theme "\\useinnertheme")
		              (:beamer-outer-theme "\\useoutertheme"))
		            ""))
       ;; Possibly limit depth for headline numbering.
       (let ((sec-num (plist-get info :section-numbers)))
         (when (integerp sec-num)
	       (format "\\setcounter{secnumdepth}{%d}\n" sec-num)))
       ;; Author.
       (let ((author (and (plist-get info :with-author)
			              (let ((auth (plist-get info :author)))
			                (and auth (org-export-data auth info)))))
             (shortauthor (plist-get info :shortauthor))
	         (email (and (plist-get info :with-email)
		                 (org-export-data (plist-get info :email) info))))
         (cond ((and author shortauthor) (format "\\author[%s]{%s}\n" shortauthor author))
               ((and author shortauthor email (not (string= "" email)))
                (format "\\author[%s]{%s\\thanks{%s}}\n" shortauthor author email))
               ((and author email (not (string= "" email)))
	            (format "\\author{%s\\thanks{%s}}\n" author email))
	           ((or author email) (format "\\author{%s}\n" (or author email)))))
       ;; Date.
       (let ((date (and (plist-get info :with-date) (org-export-get-date info)))
             (shortdate (plist-get info :shortdate)))
         (cond ((and date shortdate)
                (format "\\date[%s]{%s}\n" shortdate (org-export-data date info)))
               (t (format "\\date{%s}\n" (org-export-data date info)))))
       ;; Title
       (let ((shorttitle (plist-get info :shorttitle)))
         (cond ((and title shorttitle) (format "\\title[%s]{%s}\n" shorttitle title))
               (t (format "\\title{%s}\n" title))))
       ;; institute
       (let ((institute (plist-get info :institute))
             (shortinstitute (plist-get info :shortinstitute)))
         (cond ((and institute shortinstitute)
                (format "\\institute[%s]{%s}\n" shortinstitute institute))
               ((or institute shortinstitute)
                (format "\\institute{%s}\n" (or shortinstitute institute)))))
       (when (org-string-nw-p subtitle)
         (concat (format (plist-get info :beamer-subtitle-format) subtitle) "\n"))
       ;; Beamer-header
       (let ((beamer-header (plist-get info :beamer-header)))
         (when beamer-header
	       (format "%s\n" (plist-get info :beamer-header))))
       ;; 9. Hyperref options.
       (let ((template (plist-get info :latex-hyperref-template)))
         (and (stringp template)
	          (format-spec template (org-latex--format-spec info))))
       ;; Document start.
       "\\begin{document}\n\n"
       ;; Title command.
       (org-element-normalize-string
        (cond ((not (plist-get info :with-title)) nil)
	          ((string= "" title) nil)
	          ((not (stringp org-latex-title-command)) nil)
	          ((string-match "\\(?:[^%]\\|^\\)%s"
			                 org-latex-title-command)
	           (format org-latex-title-command title))
	          (t org-latex-title-command)))
       ;; Table of contents.
       (let ((depth (plist-get info :with-toc)))
         (when depth
	       (concat
	        (format "\\begin{frame}%s{%s}\n"
		            (org-beamer--normalize-argument
		             (plist-get info :beamer-outline-frame-options) 'option)
		            (plist-get info :beamer-outline-frame-title))
	        (when (wholenump depth)
	          (format "\\setcounter{tocdepth}{%d}\n" depth))
	        "\\tableofcontents\n"
	        "\\end{frame}\n\n")))
       ;; Document's body.
       contents
       ;; Creator.
       (if (plist-get info :with-creator)
	       (concat (plist-get info :creator) "\n")
         "")
       ;; Document end.
       "\\end{document}")))
  ;;
  :advice ((:override org-beamer-template
                      my:org-beamer-template))
  :custom
  `((org-beamer-frame-level . 2)
    (org-beamer-frame-default-options . "fragile,squeeze,c")
    (org-latex-compiler . "latexmk -pvc")
    )
  )

いまいちカッコ良くないけれど

#+AUTHOR: 担当: 佐々木洋平
#+SHORT_AUTHOR: 佐々木
#+STARTUP: overview beamer
#+INSTITUTE: 正式な所属の長い表示
#+SHORT_INSTITUTE: 短いやつ.
#+DATE: 2022年 2 月 18日(金) 17:00 〜
#+SHORT_DATE: 2022/02/18
#+LATEX_CLASS: beamer

なんて書いておくと, beamer に export した時に

\author[佐々木]{担当: 佐々木洋平}
\institute[短いやつ.]{正式な所属の長い表示}
\date[2022/02/18]{2022年 2 月 18日(金) 17:00 〜}

となる.


2022/02/20

_ Wanderlust での HTML メール表示

HTMLメール自体は諸悪の根源だと思うので滅んで欲しいと常々思っているのだけれど, outlook なんかが送ってくる multipart の text/plain が無駄な改行が多過ぎて読み辛くてかなわんので 渋々 HTML を表示させていたりする(あと, text で済む内容なのに「HTML 表示を有効にして下さい」とか強制してくるアレやコレもあるよね, 的な).

普段遣いの MUA は Wanderlust なので, text/html の表示には mime-w3m を使っていた. で, 昔の記憶が定かではない or 記憶違いなのか

まあ, 必要に応じて html リンクを踏まねばならない事はままあるので, どうやってたのかジタバタしてみたり.

結果として eww で表示する様に切り替えてた.

昔何にハマったのか, 殆ど覚えていない鳥頭. まあ, 何かハマったら, また考えよう.

eww の設定は以下

;; リンクを簡単に辿る(Hit-a-Hint) のために =ace-link= も入れておく
;; - my:d:tmp は $HOME/.cache/emacs 以下.
(leaf eww
  :preface
  (unless (file-directory-p (expand-file-name "eww" my:d:tmp))
    (make-directory (expand-file-name "eww" my:d:tmp)))
  :init
  (leaf ace-link :ensure t)
  (leaf shr
    :custom
    ((shr-use-colors    . nil)
     (shr-use-fonts     . nil)
     (shr-image-animate . nil)
     (shr-width         . 72)
     (shr-max-width     . 72)
     )
    )
  :bind (("<f2>" . eww)
         (:eww-mode-map
          ("r"   . eww-reload)
          ("o"   . eww)
          ("&"   . eww-browse-with-external-browser)
          ("b"   . eww-back-url)
          ("]"   . eww-next-url)
          ("["   . eww-previous-url)
          ("g"   . eww-top-url)
          ("h"   . backward-char)
          ("j"   . next-line)
          ("C-n" . next-line)
          ("k"   . previous-line)
          ("C-p" . previous-line)
          ("l"   . forward-char)
          ("/"   . isearch-forward)
          ("?"   . isearch-backward)
          ("n"   . isearch-next)
          ("N"   . isearch-previous)
          ("f"   . ace-link-eww))
         )
  :custom
  `((eww-bookmarks-directory
     . ,(expand-file-name "eww" my:d:tmp))
    (eww-search-prefix
     . "https://www.google.com/search?&gws_rd=cr&complete=0&pws=0&tbs=li:1&q="))
  :config
  (ace-link-setup-default)
  )

Wanderlust の html 表示は以下

(setq mime-view-text/html-previewer 'shr
      mime-setup-enable-inline-html 'shr
      mime-view-type-subtype-score-alist '(((text . plain) . 0)
                                           ((text . html)  . 1)))

ま, とりあえずは快適になったので良しとする.


2022/02/22

_ ps-printps-mule の設定

「出張手続きの書類として先方とのメールのやりとりを提出して下さい」ということで, 普段使いの MUA は Wanderlust なのでサクっと wl-summary-print-message を使って出力しようとしたんですが, まあ, 印刷結果がなかなか微妙な….

ちょっと設定を更新してみたり

(leaf ps-mule
  :if (executable-find "lpr")
  :custom
  ((ps-multibyte-buffer       . 'nil ) ;;non-latin-printer
   ;; ps-multibyte-buffer が…
   ;; - 'non-latin-printer だと `ps-mule-font-info-database-ps' を使う.
   ;; - nil だと `ps-mule-font-info-database-default' を使う.
   (ps-printer-name           . "PDF")
   (ps-paper-size             . 'a4)
   ;; (ps-n-up-printing          .  2)
   (ps-print-header           .  t)
   (ps-print-footer           .  nil)
   (ps-font-family            . 'Courier)
   (ps-font-size              . '(9 . 10))
   (ps-header-font-family     . 'Helvetica)
   (ps-header-font-size       . '(10 . 12))
   (ps-header-title-font-size . '(12 . 14))
   (ps-line-number            . nil)
   ;; (ps-line-number-font   . "Times-Italic")
   ;; (ps-line-number-font-size . 6)
   ;; (ps-line-number-start   . 1)
   ;; (ps-line-number-step    . 1)
   )
  :hook
  (defalias 'ps-mule-header-string-charset 'ignore)
  :config
  (setq ps-mule-font-info-database-default
        '((iso-8859-1
           (normal nil nil))
          (katakana-jisx0201
           (normal builtin "Ryumin-Light-Katakana")
           (bold builtin "GothicBBB-Medium-Katakana"))
          (latin-jisx0201
           (normal builtin "Ryumin-Light-Hankaku")
           (bold builtin "GothicBBB-Medium-Hankaku"))
          (japanese-jisx0208
           (normal builtin "Ryumin-Light-Ext-H")
           (bold builtin "GothicBBB-Medium-Ext-H"))
          (japanese-jisx0213-2
           (normal builtin "Ryumin-Light-Ext-H")
           (bold builtin "GothicBBB-Medium-Ext-H"))
          (japanese-jisx0213.2004-1
           (normal builtin "Ryumin-Light-2004-H")
           (bold builtin "GothicBBB-Medium-H"))
          (unicode-bmp
           (normal builtin "Ryumin-Light-Ext-H")
           (bold builtin "GothicBBB-Medium-Ext-H"))
          )
        )
  )

ps-mule-font-info-database-default は適当です. 誰か正しい指定を教えろ下さい.

(2022/02/24 追記: 機種依存文字が出なかったので, ちょっと更新)

あとは Wanderlust 側で

;; default は `lpr-bufffer'
(setq wl-print-buffer-function 'ps-print-buffer)

とでもしておく.

まあ, 設定前に比べればだいぶマシになったんだけれど, なんでマシになったのか実はわかっていないかったりする (とはいえ中華フォントが入ったり日本語が潰れていたり, ということはなくなった模様).

うーん…🤔


連絡先など
最近の日記
一覧
2006|03|04|05|06|07|08|09|10|11|12|
2007|01|02|03|04|05|06|07|08|09|10|11|12|
2008|01|02|03|04|05|06|07|08|09|10|11|12|
2009|01|02|03|04|05|06|07|08|09|10|11|12|
2010|01|02|03|04|05|06|07|08|09|10|11|12|
2011|01|02|03|04|05|06|07|08|09|10|11|12|
2012|02|03|04|08|09|10|11|12|
2013|01|02|03|04|05|06|08|09|10|11|12|
2014|01|02|04|05|06|07|08|09|10|11|12|
2015|01|02|03|04|05|06|07|09|10|
2016|02|03|
2017|01|02|03|05|06|07|09|11|12|
2018|03|06|07|10|11|12|
2019|01|02|03|04|05|07|10|12|
2020|01|02|03|04|05|08|09|10|11|12|
2021|01|02|03|05|06|07|08|09|11|12|
2022|01|02|03|04|05|06|08|10|11|12|
2023|02|03|04|06|08|09|11|12|
2024|01|02|03|
Back to Top ▲