Sunday, October 21, 2007

Ferestre transparente, compiz etc.

Am descoperit cu stupoare că doar Compiz reuşeşte să rezolve satisfăcator o mică problemă de gestiunea ferestrelor, şi anume gruparea acestora.

De exemplu, Emacs+speedbar sunt două ferestre. Când fac switch către emacs îmi apare doar emacs, speedbar rămâne undeva în fundal. În compiz (pe Gutsy Gibbon aka Ubuntu 7.10) pot să folosesc ccsm pentru a configura gruparea de ferestre.

Astfel, cu Super-S (Super este mapat în Gnome pe alt stânga) pot să încep să selectez ferestre. După ce am selectat tot, le grupez cu Super-G. Dacă dau Super-S pe un grup deja format mi le selectează pe toate.

Extraordinar de util şi pentru Gimp (care are by default două ferestre, şi fiecare poză suplimentară implică prezenţa unei noi ferestre).

Oare de ce nu există aşa ceva pentru metacity/kwin? Sau, dacă există, de ce nu e documentată chestia?

Încă ceva: cu ccsm se poate activa ring-switcher-ul (pentru schimbat între aplicaţii cu Super-Tab) care este ceva mai capabil decât switcher-ul normal care porneşte la Alt-Tab (pot selecta lucrurile cu mouse-ul, de exemplu.

Începe să nu-mi mai pară rău după timpul consumat cu upgradarea la Ubuntu 7.10. Aaah, şi s-a dat şi drumul la căldura :))

Friday, October 19, 2007

Ubgradeuri

Ieri a ieşit Ubuntu 7.10 cu compizării incluse automat. Adică mi-au buşit Alt-Tab, dar mi-au dat zoom gen Win-scroll wheel şi variaţia opacităţii cu Alt-scroll wheel.

Dacă tot m-am apucat de upgrade-uri, am zis să trec şi la Emacs (acum ca suportă caractere româneşti implicit). Ce mă atrage este indentarea mult mai inteligentă decât la alte editoare. Asta în primul rând şi asta e bine.

Ce e rău: ma atrag şi customizările în Emacs Lisp. Mă atrag atât de tare, încât am reimplementat M-/ ca C-x p cu o grămadă de cod şi mult timp pierdut. Deoarece codul respectiv va fi scos din .emacs, îl pun aici ca să fie (să nu zic că am pierdut timpul aiurea). Da, am învăţat o grămadă despre Emacs Lisp făcând acest exerciţiu inutil.

Da, aştia de la blogspot or să facă praf formatarea. Asta este.


(defun forward-uword ()
"like forward-word, but underscores are considered part of the word"
(interactive)
(if (not (forward-word))
nil
(cond ((looking-at "_+\\w") (forward-uword))
((looking-at "_+") (search-forward-regexp "_+"))
(t t))))

(defun repeat-search-backward-regexp (regexp)
(while (looking-back regexp)
(search-backward-regexp regexp)))

(defun backward-uword ()
"like forward-word, but underscores are considered part of the word"
(interactive)
(if (not (backward-word))
nil
(cond ((looking-back "\\w_+") (backward-uword))
((looking-back "_+") (repeat-search-backward-regexp "_+"))
(t t))))

(defun current-uword ()
"returns the current word with underscores as a string"
(interactive)
(let ((end (point))
(beg (save-excursion
(backward-uword)
(point))))
(buffer-substring-no-properties beg end)))

(defun list-words ()
"list the words in the buffer in a hash table, except the word at point"
(interactive)
(let ((words '())
(wstart 0)
(wend 0))
(save-excursion
(goto-char (point-min))
(while (forward-uword)
(setq wend (point))
(backward-uword)
(setq wstart (point))
(forward-uword)
(setq words (cons (buffer-substring-no-properties wstart wend)
words))))
(let ((result (makehash 'equal))
(curword (current-uword)))
(mapcar (lambda (w) (if (not (string= w curword))
(puthash w nil result)))
words)
(message curword)
result)))

(defun words-complete-symbol ()
"Perform completion on words from current buffer (ripped and
transformed lisp-complete-symbol"
(interactive)
(let ((window (get-buffer-window "*Completions*" 0)))
(if (and (eq last-command this-command)
window (window-live-p window) (window-buffer window)
(buffer-name (window-buffer window)))
;; If this command was repeated, and
;; there's a fresh completion window with a live buffer,
;; and this command is repeated, scroll that window.
(with-current-buffer (window-buffer window)
(if (pos-visible-in-window-p (point-max) window)
(set-window-start window (point-min))
(save-selected-window
(select-window window)
(scroll-up))))

;; Do completion.
(let* ((end (point))
(beg (save-excursion
(backward-uword)
(point)))
(pattern (current-uword))
(words (list-words))
(completion (try-completion pattern words)))
(cond ((eq completion t))
((null completion)
(message "Can't find completion for \"%s\"" pattern)
(ding))
((not (string= pattern completion))
(delete-region beg end)
(insert completion)
;; Don't leave around a completions buffer that's out of date.
(let ((win (get-buffer-window "*Completions*" 0)))
(if win (with-selected-window win (bury-buffer)))))
(t
(let ((minibuf-is-in-use
(eq (minibuffer-window) (selected-window))))
(unless minibuf-is-in-use
(message "Making completion list..."))
(let ((list (all-completions pattern words)))
(setq list (sort list 'string<)) (let (new) (while list (setq new (cons (if (fboundp (intern (car list))) (list (car list) " ")
(car list))
new))
(setq list (cdr list)))
(setq list (nreverse new)))
(if (> (length list) 1)
(with-output-to-temp-buffer "*Completions*"
(display-completion-list list pattern))
;; Don't leave around a completions buffer that's
;; out of date.
(let ((win (get-buffer-window "*Completions*" 0)))
(if win (with-selected-window win (bury-buffer))))))
(unless minibuf-is-in-use
(message "Making completion list...%s" "done")))))))))

(global-set-key "\C-xp" 'words-complete-symbol)