Whenever I tex my math or tech homework I'm using lisp as a calculator as it knows how to handle fractions and as I'm using Emacs it's just a buffer away. So yesterday, while checking my calculations I discovered this imho funny piece of lisp code: (* ** *)
. Which multiply the second-last with the last return value, nothing you would use in a program, but quite usefull in the REPL.
Sunday, June 20, 2004
* ** ***
Monday, June 14, 2004
the end is near
The semester ends soon (July 14th), which means I'm learning for exams. Vocabulary and grammar for finnish, vocabulary and grammar for formal CS, ideas & whatsoever for technical CS and IMG (IT, Man & Society). At the moment I'm reading “F2 - Automaten und formale Sprachen”, which will be followed by a short repitition of “F1 - Formale Gundlagen der Informatik”.
Thursday, June 03, 2004
php-complete-function ready for testing
I think I have completed it and would love to have some feedback, especially if it works with XEmacs. You can download it here, before you use it however you should M-x customize-group RET php RET
it and set php-manual-path
to directory which contains the php manual in many html files or generate a file with one function name per line and set php-completion-file
to it. If you want to include completions from your tag file you must visit-tags-file
. The key combination for completion is M-TAB
, if that doesn't suit you rebind it.
php-completion-table
I did solve the problem of getting the right table and solved a another problem. The right completion table is now computed by etags-tags-completion-buffer
and the other problem was that I didn't join the right tables, not having thought about how it was done, the incorret code would do nothing because (mapatoms (lambda ...) nil)
should do nothing.
(defun php-completion-table () (or php-completion-table (let ((table (make-vector 1022 0)) (php-completion-buffer (find-file-noselect php-completion-buffer-file)) (my-tags-table (if (functionp 'etags-tags-completion-table) (with-current-buffer (get-file-buffer tags-file-name) (etags-tags-completion-table)) nil))) (save-excursion (set-buffer php-completion-buffer) (goto-char (point-min)) (while (re-search-forward "^\\([-a-zA-Z0-9_.]+\\)\n" nil t) (intern (buffer-substring (match-beginning 1) (match-end 1)) table))) (when my-tags-table ;; Combine the tables. (mapatoms (lambda (sym) (intern (symbol-name sym) table)) my-tags-table)) (setq php-completion-table table))))
Fanta the german drink
I just heard it on the radio and could not believe it so I checked the Wikipedia entry for Fanta. Basically there was shortage of ingredients to produce coca-cola in Third Reich and thus a new drink Fanta (from fantastisch - fantastic) was invented.
php-complete-function
Dissapppointed by the poor php-mode for emacs, I am trying to improve it by adding php-complete-function
. I can now complete most of the php functions (methods of objects are missing), but I'm struggling on how to mix the php functions with user defined functions from TAGS. I somehow can't get the right tags-completion-table and merge it with my php-completion-table.
(defcustom php-completion-buffer-file "/home/tekai/emacs/php_functions" "*Path to the file which contains the function names" :type 'string :group 'php) (defvar php-completion-table nil "Obarray of tag names defined in current tags table.") ;; Define function name completion function (defun php-complete-function () "Complete the function name at the point from known PHP functions." (interactive) (let ((pattern (funcall (or find-tag-default-function (get major-mode 'find-tag-default-function) 'find-tag-default))) beg completion (php-functions (php-completion-table))) (search-backward pattern) (setq beg (point)) (forward-char (length pattern)) (setq completion (try-completion pattern php-functions nil)) (cond ((eq completion t)) ((null completion) (message "Can't find completion for this \"%s\"" pattern) (ding)) ((not (string= pattern completion)) (delete-region beg (point)) (insert completion)) (t (message "Making completion list...") (with-output-to-temp-buffer "*Completions*" (display-completion-list (all-completions pattern php-functions))) (message "Making completion list...%s" "done")))) ;;(complete-tag) ;;(message "php-complete-function not implemented yet") ;; how to read the list of functions from a separate file? ) (defun php-completion-table () (or php-completion-table (let ((table (make-vector 1022 0)) (php-completion-buffer (find-file-noselect php-completion-buffer-file)) (tags-table (if (functionp 'tags-completion-table) (progn (visit-tags-table-buffer) (tags-completion-table)) nil))) (save-excursion (set-buffer php-completion-buffer) (goto-char (point-min)) (while (re-search-forward "^\\([-a-zA-Z0-9_.]+\\)\n" nil t) (intern (buffer-substring (match-beginning 1) (match-end 1)) table))) (if tags-table ;; Combine the tables. (mapatoms (lambda (sym) (intern (symbol-name sym) tags-table)) php-completion-table)) (setq php-completion-table table))))
The php_functions file has one function name per line.
Aside: I find the poor quality of php-mode somewhat strange, maybe I shouldn't compare it with slime, but I expected it to do better, PHP is not that new. But maybe most PHP coders don't grasp (e)lisp, use IDEs and are just codemonkeys who doing are doing most of their work copy&paste. But really why is the php-mode that bad?