;; -*- coding: utf-8 -*- ;; 2010-09-03 ;; Replace “…” to one of 〔…〕, 「…」, 【…】 (defun cap-first-letter () "Replace “

a…” to cap “

A…” " (interactive) (let () (query-replace-regexp "

\\([a-z]\\)" ; (concat "

" (upcase (match-string 1 ))) (concat "

" (upcase "t")) ;(upcase (match-string 1 )) ; "

\\,(upcase \\1)" ;; "

\\,(upcase \\1)" ) )) ;; (defun code-bracket-to-html-tag () ;; "Replace all 「…」 to in current buffer." ;; (interactive) ;; (let (changedItems) ;; ;; (setq changedItems (make-hash-table :test 'equal)) ;; (setq changedItems '()) ;; (save-excursion ;; (goto-char (point-min)) ;; (while (search-forward-regexp "《\\([^》]+?\\)》" nil t) ;; ;; (puthash (match-string 1) "t" changedItems) ;; (setq changedItems (cons (match-string 1) changedItems ) ) ;; (replace-match "\\1" t) ;; ) ;; (goto-char (point-min)) ;; (while (search-forward-regexp "〈\\([^〉]+?\\)〉" nil t) ;; ;; (puthash (match-string 1) "t" changedItems) ;; (setq changedItems (cons (match-string 1) changedItems ) ) ;; (replace-match "\\1" t) ;; ) ;; ) ;; (with-output-to-temp-buffer "*changed items*" ;; ;; (maphash ;; ;; (lambda (myTitle myKey) ;; ;; (princ myTitle) ;; ;; (princ "\n") ;; ;; ) ;; ;; changedItems) ;; (mapcar ;; (lambda (myTitle) ;; (princ myTitle) ;; (princ "\n") ;; ) ;; changedItems) ;; ) ;; )) (defun code-bracket-to-html-tag2 () "Replace all 「…」 to in current buffer." (interactive) (let () (goto-char (point-min)) (while (search-forward-regexp "「\\([^」]+?\\)」" nil t) (if (y-or-n-p "Replace this one?") (replace-match "\\1" t) ) ) (message "found no more.") )) (defun code-bracket-to-html-tag (p1 p2) "Replace all 「…」 to . Works on current line or text selection. Generate a report of the replaced strings in a separate buffer." (interactive (if (region-active-p) (list (region-beginning) (region-end)) (list (line-beginning-position) (line-end-position)) ) ) (let (changedItems) (setq changedItems '()) (save-excursion (save-restriction (narrow-to-region p1 p2) (goto-char (point-min)) (while (search-forward-regexp "「\\([^」]+?\\)」" nil t) (setq changedItems (cons (match-string 1) changedItems ) ) (replace-match "\\1" t) ) ) ) (with-output-to-temp-buffer "*changed items*" (mapcar (lambda (innerText) (princ innerText) (princ "\n") ) changedItems) ) )) (defun title-bracket-to-html-tag (p1 p2) "Replace all 〈…〉 to . Also replace 《…》 to …. Works on current line or text selection. Generate a report of the replaced strings in a separate buffer." (interactive (if (region-active-p) (list (region-beginning) (region-end)) (list (line-beginning-position) (line-end-position)) ) ) (let (changedItems) ;; (setq changedItems (make-hash-table :test 'equal)) (setq changedItems '()) (save-excursion (save-restriction (narrow-to-region p1 p2) (goto-char (point-min)) (while (search-forward-regexp "《\\([^》]+?\\)》" nil t) ;; (puthash (match-string 1) "t" changedItems) (setq changedItems (cons (match-string 1) changedItems ) ) ;; (setq case-fold-search nil) (replace-match "\\1" t) ) (goto-char (point-min)) (while (search-forward-regexp "〈\\([^〉]+?\\)〉" nil t) ;; (puthash (match-string 1) "t" changedItems) (setq changedItems (cons (match-string 1) changedItems ) ) (replace-match "\\1" t) ) )) (with-output-to-temp-buffer "*changed items*" ;; (maphash ;; (lambda (myTitle myKey) ;; (princ myTitle) ;; (princ "\n") ;; ) ;; changedItems) (mapcar (lambda (myTitle) (princ myTitle) (princ "\n") ) changedItems) ) )) (defun curly-quotes-to-emacs-function-tag (p1 p2) "Replace “word” to HTML markup for elisp function in text selection or current line. For example, the text:

Call “sort-lines” to sort.

becomes

Call sort-lines to sort.

When call in lisp program, the p1 p2 are region positions. Note: a word is changed only if all of the following are true: ① It is enclosed in

tag, or