texts: Export Javascript source block to script tag in HTML when exporting Org file to HTML

texts:
To avoid the XY problem, let me say that what I actually want is to embed Javascript code into <script> tags in the HTML files produced via Org mode export, in such a way that (1) the Javascript code is included in the Org file (not a separate Javascript file), and (2) it is very easy to edit the Javascript in a Javascript specific major mode. The question title is only one way to achieve that.

Currently to embed Javascript in the resulting exported HTML I use:

#+BEGIN_EXPORT html
<script type="text/javascript">
 // javascript code goes here
</script>
#+END_EXPORT

That works fine, of course, but I'd like to edit the Javascript code in a Javascript major mode. Using C-' on an HTML block sensibly opens a buffer in HTML mode. So I've been using temp buffers I manually open and put in Javascript mode.

To embed code in an Org file that's conveniently editable in the correct major mode, you can use source blocks. Is there a way to get that Javascript code to export into a <script> tag? Or some other convenient way to get what I want?

EDIT: Updated the #+BEGIN_HTML to #+BEGIN_EXPORT html for the shiny new Org 9.0, per @mutbuerger's suggestion.


texts: End of buffer in COMMIT_EDITMSG buffer when i space

texts:
I keep hitting a strange issue with the COMMIT_EDITMSG buffer on some occasions I can not insert a space, I can type all other alpha numeric characters just not insert a space between words.

When i hit space End of buffer is displayed in the mini buffer, I have a hunch another plugin is modifying this key because its used by a modal plugin in other modes, anyone encountered anything similar or how can I debug because there is technically no errors.


texts: Trying to save open buffers to file every n seconds in emacs, why does this solution not work?

texts:
I want to save all open buffers to the relevant files (not an autosave file) at some regular interval (between 5 and 1 minutes).

This seemed like it was the correct solution:

; In ~/.emacs file make following changes.

(require 'auto-save-buffers)
(run-with-idle-timer 5 t 'auto-save-buffers)

But eval-region on this code gives the following error message: eval-region: Cannot open load file: no such file or directory, auto-save-buffers. I run emacs 24.4.

Is the auto-save-buffers functionality no longer available? Is there some other way to do what I want? Is it actually the right tool for saving to the file I have opened rather than a separate autosave file?

I have seen auto-save-buffers-enhanced in the list of available packages (ie. M-x list-packages) and using that instead of auto-save-buffers might be an option, but I'd prefer a solution that only requires things that come with emacs by default.


texts: Display word count in modeline without lag

texts:
Problem
Stopped using wc-mode as it is not snappy anymore (as text writing usually is) with text document of 10k words. It appears that it counts the whole buffer after every change which seems to make it slow as logged here. A recent change was made to speed it up, but still produces considerable lag.
Partial Solution
There is a "solution" here, but it is so hard for me to implement it as I am not familiar with Lisp and inner workings of Emacs. There are two functions wc-buffer and wc-region, which are empty in the answer (below), for which I have no clue what should be in the function.
;; Function that counts words in buffer
(defun wc-buffer ()
  ...)

;; Function that counts words in a region
(defun wc-region (rbeg rend)
  ...)

(defvar-local a1 nil)
(defvar-local a2 nil)
(defvar-local curr-wc nil)

(defun init-function ()
  (interactive)
  (save-excursion
    (setq curr-wc (wc-buffer))))

(defun wc-update-before (change-beg change-end)
  (setq pos1 (max 1 (1- change-beg)))
  (setq pos2 (min (point-max) (1+ change-end)))

  (setq a1 (wc-region pos1 pos2)))

(defun wc-update-after (change-beg change-end prev-len)
  (if (bound-and-true-p a1)
      (progn
        (setq pos1 (max 1 (1- change-beg)))
        (setq pos2 (min (point-max) (1+ change-end)))

        (setq a2 (wc-region pos1 pos2))

        (setq curr-wc (+ curr-wc (- a2 a1))))
      nil))

(init-function)
(add-hook 'before-change-functions #'wc-update-before nil t)
(add-hook 'after-change-functions #'wc-update-after nil t)
(setq inhibit-modification-hooks nil)

Help
I ask for someone either to tell me explicitly what goes in these functions or suggest alternatives for counting words and not having lag while displaying them in the mode-line.
Reproducing
You can reproduce this by: installing wc-mode and enabling it and then when you have more than 10k words, you can expect (depending on your PC) quite some lag while typing. It's not snappy.


texts: How to turn on autocompletion for Company mode?

texts:
I have installed Company mode per http://company-mode.github.io/ and added the word list as in https://github.com/wushuaibuaa/emacscompanywords. But working in a text file with the extension .txt, even though I press M-x company-mode, the autocompletion does not start. What else do I need to do, to get autocompletion with Company mode?
Emacs 26.3 / OS X 10.15.7


texts:
I started using ranger and it's awesome, but one thing bothers me: It keeps every visited folder open in a buffer, so it floods my buffer list.

There are two options that seem to be made to solve this problem:

Ranger Cleanup Eagerly
Ranger Cleanup On Disable

The first one makes ranger unusable as I cannot open folders anymore in ranger-mode (could be a bug).
The second one sounds exactly like what I am looking for, but has no effect either.

What am I doing wrong?


texts:
Saveplace is a nice tool to remember where I have left of in a file. But for Org files it causes me problems when I quit emacs in the middle of a heading.

My current try to deactivate it in org-files is to use a hook and set 'save-place
 to nil.

  (require 'saveplace)
  (setq save-place-file (concat user-emacs-directory "saveplace.el") )
  (setq-default save-place t)

  (defun max/org-mode-hook ()
    (setq save-place nil)
    (flyspell-mode))
  (add-hook 'org-mode-hook 'max/org-mode-hook)

This works most of the time but for a strange reason it is sometimes still activated in org-mode and I start at the last position instead of line 1 when I open an org file. I'm not sure how to produce this reliable.

Any tips how I can make the deactivation of saveplace reliable in org-mode?


texts: Modify environment using a bash script of an already running emacs

texts:
I have Emacs open with lots of files. I want to compile within Emacs, but first I have to source some setup.sh bash script that modifies the environment. How do I do that?
This post says it's impossible.  This man page does not help.  This ergoemacs page targets a single environmental variable only, which make me feel like it might be possible!
I don't want to overload the Emacs compile function, as I just want to run the script once in a while, not for every compilation.


texts: Override a function locally, but allow calls to the original function

texts:
The advice feature allows modifying the behavior of a function globally. An advice definition can make calls to the original function.

(defadvice foo
  (around foo-bar activate compile)
  "Always set `qux' to t when running `foo'."
  (let ((qux t))
    ad-do-it))

The cl package provides the flet macro to override a function locally.

(defun foo ()
  "global")
(flet ((foo ()
          "local"))
  (some-code-that-calls-foo))

That doesn't permit a reference to the original foo function. What if the local override needs to call the original function?

(defun foo ()
  "global")
(flet ((foo ()
          (concat (foo) "+local")))
  ;; this will cause an infinite loop when (foo) is called
  (some-code-that-calls-foo))

This straightforward approach doesn't work, for good reason: (foo) is a recursive call to the local definition.

What's a non-cumbersome way of locally overriding a function, that allows calling the original function from the override code?

Application: monkey-patching some existing code, in a case where foo should not be rebound globally, but the code needs to call the original. Here's the latest example I've been wanting:

(defadvice TeX-master-file
  (around TeX-master-file-indirect-buffer activate compile)
  "Support indirect buffers."
  (flet ((buffer-file-name (&optional buffer)
           (<global buffer-file-name> (buffer-base-buffer buffer))))
      ad-do-it)))

I wanted to rebind buffer-file-name locally, and call the original buffer-file-name. Ok, in this specific case, there's a workaround, which is to use the buffer-file-name variable. But the point of my question here is the general technique. How can I bind a function (here buffer-file-name) locally but call the global definition from my redefinition?

This is for my .emacs, which I keep working in Emacs 19.34, so solutions that require Emacs 24.4 are out. I do prefer solutions that cope with lexical binding cleanly though — but monkey-patching is inherently about dynamic binding.


texts: How do I associate a file such as git's `COMMIT_EDITMSG` with a specific mode?

texts:
I was doing following solution for markdown files: How do I associate a file extension with a specific mode?

(autoload 'markdown-mode "markdown-mode.el"
  "Major mode for editing Markdown files" t)

(setq auto-mode-alist
      (cons '("\\.md" . markdown-mode) auto-mode-alist))

I want to do it same operation for text show up when I want to commit a message for git. When I type git commit a COMMIT_EDITMSG file shows up which has Fundamental mode. Since COMMIT_EDITMSG does not have any extention I was not able to match it into markdown-mode as I done for *.md files.

CRM Buffer                 Size Mode             File
.   COMMIT_EDITMSG         1259 Fundamental      ~/folder/.git/COMMIT_EDITMSG

My .gitconfig file setup:

[core]
    pager = less -r
    editor = TERM=xterm-256color emacsclient -t

[Q] Is there a way to open git's COMMIT_EDITMSG file in markdown-mode?


texts: use-package won't load helm for projectile

texts:
I'm trying to use use-package to load projectile.  Projectile uses helm for completion, which I'm also loading with use-package.  Since projectile and helm have :bind sections I believe they're both being lazy-loaded.

My problem is that when I try to open a project in projectile it gives me the error message 'No projects need to be removed' after I've pressed C-c p.  If I C-g to get out of that, and then press C-c p p I get the error message Please install helm from https://github.com/emacs-helm/helm.

If I open up my config file and evaluate the use-package form for helm then the 'open project' feature works great in projectile (i.e., C-c p p puts me into helm to open a known project).

My gut feeling is that use-package is deferring the loading of both helm and projectile.  Pressing the projectile key combo must load projectile but not helm (even though I've got an :after section in my projectile config saying to load after helm.

Indeed - I can force helm to load (by invoking helm-recentf), after which projectile's open project feature works great.

How do I force use-package to load both projectile AND helm, when a key combo for projectile is pressed?

Here's what I've got for helm & projectile in my config file:

(use-package helm
    :ensure t
    :bind (
        ("C-x b" . helm-buffers-list)
        ("C-S-y" . helm-show-kill-ring)
        ("C-x m" . helm-M-x)
        ("C-x C-f" . helm-find-files)
        ("C-r" . helm-recentf)
    )
    :config
        (helm-mode 1)
        (setq helm-ff-file-name-history-use-recentf t)
)

(use-package projectile
  :ensure t
  :pin melpa-stable
  :after helm
  :bind-keymap (
      ("C-c p" .  projectile-command-map)
  )
  :config
      ;; (define-key projectile-mode-map (kbd "s-p") 'projectile-command-map)
      ;; (define-key projectile-mode-map (kbd "C-c p") 'projectile-command-map)
      (projectile-mode +1)
      (setq-default
          projectile-completion-system 'helm
          projectile-switch-project-action #'projectile-find-file-dwim
          ;; Display project name, or else remove this section
          projectile-mode-line '(:eval (if (string= "-" (projectile-project-name) ) " " (format " [%s] " (projectile-project-name) ) ) )
      )
)

EDIT:  If I add :demand t to the use-package for helm then projectile's open-project works great.  So it looks like the problem is that use-package is loading projectile, but not it's dependencies.

EDIT 2: Is this a bug in use-package?


texts:
Why evals (keymapp 'kmacro-keymap) to t,
and (keymapp 'kmacro-step-edit-map)  to nil?

Both look like ordinary keymaps to me.


texts: How to switch org-babel-execute-src-block to use y-or-n-p?

texts:
In short, I want org-babel's prompt to accept a single y/n keypress instead of typing it out and pressing enter, but I don't want to replace all such prompts globally.

I've seen information on changing to y-or-n-p as the global default via defalias, or turning off the prompt specific to org-babel completely via org-confirm-babel-evaluate, but not how to simply shorten the prompt.  I see notes on yes-or-no.el for making functions customizable, but it doesn't seem like that applies to org-babel.

In this particular case (imho), it's important enough to preserve the prompt, but not important enough to justify typing 4 characters to do so each time.

I'm sure there's an easy way to do this, but I'm not finding it.


texts: Why does multiple cursors use the same char for all cursors with zap-to-char but not with zap-up-to-char?

texts:
This a follow up to my earlier question Why does multiple-cursors use the same char for all cursors with iy-go-to-char, but not with zap-up-to-char?.

As I describe in that question, for some commands that prompt for a character in the mini-buffer multiple-cursors will repeat the prompting for each cursor, but for others it will happily prompt only once and use that character for all cursors. In particular, for iy-go-to-char multiple-cursors prompts only once, but for zap-up-to-char it prompts per cursor.

Now, oddly enough for zap-to-char the prompting also happens only once, not once per cursor! My question is why does this happen? As far as I can tell the difference is caused by their different calls to interactive:

zap-up-to-char uses the seemingly sensible (interactive "p\ncZap up to char: "),
zap-to-char instead has:

(interactive (list (prefix-numeric-value current-prefix-arg)
                   (read-char "Zap to char: " t)))

That is indeed the cause because taking the implementation of zap-up-to-char from misc.el and replacing the interactive call with one similar to the one zap-to-char uses produces a version of zap-up-to-char that, when used with multiple-cursors, only prompts once
(not once per cursor):

(defun mc-friendly/zap-up-to-char (arg char)
  (interactive (list (prefix-numeric-value current-prefix-arg)
                     (read-char "Zap up to char: " t)))
  (let ((direction (if (>= arg 0) 1 -1)))
    (kill-region (point)
                 (progn
                   (forward-char direction)
                   (unwind-protect
                       (search-forward (char-to-string char) nil nil arg)
                     (backward-char direction))
           (point)))))

Why does changing the call to interactive have that effect?


texts:
I'm following these instructions https://www.gnu.org/software/emacs/manual/html_node/emacs/Holiday-Customizing.html to try and add Colombian holidays but I haven't been able to add holidays of the form "on  the 29th of June if its a Monday or on the next monday".

Can anyone help me with a holiday-sexp that will achieve this?

Note: I'm an elisp noob


texts: How to implement foreign key like features in org-mode tables?

texts:
I am using tables in org mode to track habits. There is a global table with each row as

| Date             | Habit1 | Habit2 | Habitn |
|                  | streak | streak | streak |
|------------------+--------+--------+--------|
| <2017-07-02 Sun> |      1 |      1 |     31 |
| <2017-07-03 Mon> |      2 |      2 |     32 |

Each habit column would specify no of days that I am successful at maintaining the habit(something like a winning streak). But it may be necessary to record additional information or notes about each habit.

For this I use separate detailed habit tables. As an example, consider habit of waking at 6:00 AM.

** Morning wake

| Date             | MW streak | MW time | No of hrs slept |
|------------------+-----------+---------+-----------------|
| <2017-07-02 Sun> |         1 |    6:00 | 7               |
| <2017-07-03 Mon> |         2 |    5:55 | 6               |

The problem with this is redundancy.
What would be optimal is to record data for each day under each habit table only, instead of recording data twice under each habit table and the global table. Changes in column 2 of each habit table should then be reflected automatically in the global table.

While not exactly the same, this is somewhat similar to the foreign key concept in databases. Is there any way to implement this?


texts: enlarge font of functions only in C code

texts:
I am trying to do exactly this for my C code, but once I edit latex, the setting is still active in uncomfortable places. I need to preserve the setting once I exit emacs and in all the buffers with C code.

How can I restrict the behavior to only buffers with C code?

This is what I have in .emacs

(defun my-c-mode-faces ()
  '(font-lock-comment-face ((t (:foreground "dark gray"))))
  '(font-lock-function-name-face ((t (:foreground "#fce94f" :weight bold :height 1.5))))
  '(font-lock-keyword-face ((t (:foreground "#b4fa70" :weight bold)))))
(add-hook 'c-mode-hook 'my-c-mode-faces)


texts: I'd like to use ivy completion to select items from my hydra rather than using the specified keymap. The use case would be for a very large hydra. I could create nested hydras, but I want to be lazy and just keep adding stuff to one large hydra without spending time organizing or formatting it. Technically, a hydra isn't required for the solution. Could also just be a list of functions, preferably with hints, and a method to select them via ivy. Thanks.


texts: I successfully managed to add birthdays with org-contacts using the :BIRTHDAY: property, but what about some other kind of anniversaries such as wedding anniversaries? How can I set them? Can I use the :WEDDING: property for example?


texts: copy paste from/to GUI Emacs not working -- Windows 7

texts:
I have an issue with copy and paste from or to Emacs (GUI); as precised in the title, I'm using Windows 7. The Emacs version is 25.1.1

kill and yank are working properly though ; to copy or paste, I have to use the mouse, which is annoying.

I have nothing special in my .emacs file, I added the following lines but nothing has changed :

(setq select-enable-primary t)
(setq select-enable-clipboard t)
(setq save-interprogram-paste-before-kill t)

thanks in advance for your insights.


texts: Failing to convert Japanese org-mode document to Latex

texts:
I am writing Japanese Org mode note and need to convert it into Latex.

I defined the japanese latex class in my config file as follow:

(with-eval-after-load 'org
  (add-to-list 'org-latex-classes
              '("japanese"
                "\\documentclass{jsarticle}
    [NO-DEFAULT-PACKAGES]
    [PACKAGES]
    [EXTRA]"
                ("\\section{%s}" . "\\section*{%s}")
                ("\\subsection{%s}" . "\\subsection*{%s}")
                ("\\subsubsection{%s}" . "\\subsubsection*{%s}")
                ("\\paragraph{%s}" . "\\paragraph*{%s}")
                ("\\subparagraph{%s}" . "\\subparagraph*{%s}")))

Then, I press C-c C-e l o (export to Latex as PDF file and open). However, I got
error as below.

Latexmk: This is Latexmk, John Collins, 17 Jan. 2018, version: 4.55.
Rule 'pdflatex': Rules & subrules not known to be previously run:
  pdflatex
Rule 'pdflatex': The following rules & subrules became out-of-date:
      'pdflatex'
------------
Run number 1 of rule 'pdflatex'
------------
------------
Running 'pdflatex -interaction nonstopmode  -recorder  "week3.tex"'
------------
Latexmk: applying rule 'pdflatex'...
This is pdfTeX, Version 3.14159265-2.6-1.40.19 (TeX Live 2018) (preloaded format=pdflatex)
restricted \write18 enabled.
entering extended mode
(./week3.tex
LaTeX2e <2018-04-01> patch level 3
Babel <3.20> and hyphenation patterns for 84 language(s) loaded.
(/usr/local/texlive/2018/texmf-dist/tex/platex/jsclasses/jsarticle.cls

! LaTeX Error: This file needs format `pLaTeX2e'
              but this is `LaTeX2e'.

So, the Org-mode is using the latexmk, but the latexmk is using the pdflatex.
As far as I know, the latexmk should automatically use the platex. After the failed
org-to-latex process, I ran latekmk name-of-file.tex normally from the terminal with
success. What is the problem here? How should I fix it?

I am using emacs 26.1 (spacemacs) and org mode 9.1.14.


texts:
The usual behavior of comment-line is to move point to the next line.
When commenting code within an Org source block, however, the point will jump to some previous line.
For example, say that point is at |:
#+begin_src emacs-lisp
  (defun hello ()
    "Say hi."
    (interactive)|
    (message "Hello, world!"))
#+end_src

When comment-line is called, the current line is commented, but point also moves to the indent of the previous line:
#+begin_src emacs-lisp
  (defun hello ()
    |"Say hi."
    ;; (interactive)
    (message "Hello, world!"))
#+end_src

Ideally, I would like point to not move at all (relative to the adjacent characters prior to (un)commenting) but would at least like comment-line to behave in a source block like it does outside of one.
I've tried a variety of suggested answers.  They all move point similarly.  It looks like comment-or-uncomment-region is the typical entry point.  This function leads down quite a labyrinth.  AFAIK, it ultimately hinges on the comment-region-function which is comment-region-default-1 by default.  Stepping through, it's not clear to me which part moves point to a previous line.


texts: Wrong file path when saving through "customize" interface

texts:
I've just started using emacs recently and it's fist time i try to configure it.
I have following setup under Windows 7:

"...\emacs\config\.emacs"

"...\emacs\emacs-bin-w64-25.0.94-O2\..."

"...\emecs\emacs.exe" - this is actually a shortcut to emacs located in above directory.

Shortcut target:

"...\emacs\emacs-bin-w64-25.0.94-O2\emacs\bin\runemacs.exe -q -l config.emacs"

Start in:

"...\emacs\"

Above works just fine but I would like to be able to change settings using Custom mode. So in .emacs I've added following line:

(user-init-file (concat (pwd) "config/.emacs")

But it turns out that with this setting the "1 = Save for future session" option is gone when I try to save changes done in Custom mode.

So I added next line after that:

(setq custom-file user-init-file)

Now both variables store correct path to .emacs file. At least they store path I expect which is:

"...\emacs\config\.emacs"

And "1 = Save for future session" option is available back again but the problem occur when I try to use it. The minibufer give me this:

  A buffer is visiting
  .../emacs/emacs-bin-w64-25.0.94-O2/emacs/share/info/Directory
  .../emacs/config/Directory
  .../emacs/config/.emacs; proceed? n user-error:
  Aborted

Basically it adds two additional paths to the one I specified. Why is that and how to fix it?


texts: How would you explain Emacs to a non-technical person?

texts:
In the spirit of How can I explain the meaning of LaTeX to my grandma?

Emacs is wonderful editor for any text-based purpose—this much is clear to those of us who use it.  Often times I'm trying to explain to one of my friends why I use something that 'looks so old' and I struggle to find a good answer.  I'm not necessarily interested in 'converting' them to use Emacs; like I said—they don't necessarily have a reason to.  I just want to explain why I use Emacs as opposed to Visual Studio, Sublime, Atom, or any of the flashy-and-featureful graphical editors.  What makes it the best choice among these?


texts: Refresh agenda for (dynamic) current buffer

texts:
When I use this custom agenda (below) for a current buffer, the agenda builds correctly. But if I try to refresh it or move the date with f or b I get errors like: if: Wrong type argument: stringp, nil and let*: Args out of range: 0, 0
(setq org-agenda-custom-commands
   '(
     ("o"                                ;; Key
      "todays agenda for current buffer" ;; Description
      agenda                             ;; Type agenda
      ""                                 ;; Match expression
      ((org-agenda-files `(,(buffer-file-name)))
       (org-agenda-span 1))              ;; Options
     )))

How can I make the agenda refreshable?


texts:
I just installed emacs24 on my Ubuntu 14.04 LTS OS as follows:

$ sudo apt-get install emacs24

When I open emacs, I get the following errors (duplicate messages removed):

  eieio/eieio.elc:Error: Forgot to expand macro eieio-object-p

  eieio/eieio-base.elc:Error: Forgot to expand macro eieio-object-p

  ede/ede-source.elc:Error: Forgot to expand macro eieio-object-p

  srecode/srecode-dictionary.elc:Error: Forgot to expand macro eieio-
  object-p

  srecode/srecode-map.elc:Error: Forgot to expand macro eieio-object-p

  ede/ede-source.elc:Error: Forgot to expand macro eieio-object-p

  semantic/semantic-debug.elc:Error: Forgot to expand macro eieio-object-p

  semantic/bovine/bovine-debug.elc:Error: Forgot to expand macro eieio-object-p

  common/pulse.elc:Warning: interactive-p' is an obsolete function (as of
      23.2); usecalled-interactively-p' instead.

  semantic/semanticdb.elc:Error: Forgot to expand macro eieio-object-p

I've Googled around, and I'm getting the impression that these errors likely have something to do with the version of CEDET I'm using.  There don't seem to be any canonical solutions to this problem yet on the internet -- and I can't find anything here on SE.

I don't know anything about CEDET.  Searching for it with apt-cache returns nothing:

$ sudo apt-cache search cedet

Is there a way I can fix this with my current installation, using apt-get?  If not, what exactly should I do?


texts: Add expressions to LaTeX-electric-left-right-brace

texts: I would want to "electrically" insert | or \right| when typing | or \left| in AucTeX and can't quite figure out how to add characters to AucTex-electric. A list of already defined completions can be found here. Can anyone help me with this issue?


texts:
I wanted to customize org-meta-line to make the source code headers look smaller, I'm using this line:

(set-face-attribute 'org-meta-line nil :height 0.5 :slant
 'normal :foreground "#C0C0C0" )

as mentioned here

it looks like this:

but I get this error when my init.el is being loaded:

Warning (initialization): An error occurred while loading
‘/home/kronolynx/.emacs.d/init.el’:

error: Invalid face, org-meta-line

How can I fix the error?


texts: Setting and activating the default input method

texts:
How can I configure Emacs to set the default input method for all new buffers? I'd like to use polish-slash everywhere.

I use Emacs 24.3.1.

I am interested in a solution which could be pasted into init.el so I can easily reuse this config between my machines.

Using just (setq default-input-method "polish-slash") in init.el does not work for me:

C-h v default-input-method returns "polish-slash".
C-h v current-input-method returns nil in probably any buffer. I checked init.el and *scratch*.


texts: Stop indenting second blank line after end of the list

texts:
I try to configure org mode in the way that it doesn't indent second blank line after last item of the list. Is there a way to achieve this?
Example:
- All of the words in Lorem Ipsum have flirted with me - consciously or unconsciously.
- That's to be expected.

  <this is still indented by default, I try to make it unindented by default>


texts: How to forward localhost ports from remote server when using tramp?

texts:
How to forward localhost  ports from the remote server when using tramp, like one can do with ssh as follows:
ssh -L <local port>:localhost:<remote port> <user_id>@<server_ip_addr>


texts: Custom ID is rendered in LaTex with org mode

texts:
I'm a noob in Emacs org mode. I convert a note of my friend's from .lyx to .tex with lyx then I use pandoc to convert it into .org. As default under heading I find:

:PROPERTIES:
:CUSTOM_ID: title-of-chapter
:END:

But when i run C-c C-e l p to interpret with LaTeX I found ":CUSTOM_ID: title-of-chapter" rendered as pdf. What's happening?


texts: Evaluating (ivy-mode 0) in a buffer kills ivy across all the other buffers, too. How to stop ivy in a specific buffer only (I don't need it in ERC, where i want TAB to give me a list of all the people in the channel, not just ten of them).


texts: Why do parts of my Emacs buffer turn invisible when I'm writing elisp?

texts:
When I'm writing elisp code, parts of the buffer that I press enter on turn invisible (i.e. they get the property invisible set to t). I haven't been able to reproduce this reliably, because it doesn't happen when I write nonsensical code to just produce some lines, but it happens sometimes.

Here is what I know:

I'm using Emacs 26.1 on Mac OS
Here is the list of active modes when I press C-h m: Enabled minor modes: Auto-Composition Auto-Compression Auto-Encryption
Blink-Cursor Cl-Old-Struct-Compat Diff-Auto-Refine Electric-Indent
Erc-Autojoin Erc-Button Erc-Fill Erc-Irccontrols Erc-List Erc-Match
Erc-Menu Erc-Move-To-Prompt Erc-Netsplit Erc-Networks Erc-Noncommands
Erc-Pcomplete Erc-Readonly Erc-Ring Erc-Stamp Erc-Track Erc-Track
File-Name-Shadow Flx-Ido Font-Lock Global-Font-Lock Global-Voice-Lock
Ido-Everywhere Menu-Bar Mouse-Wheel Projectile Shell-Dirtrack Tooltip
Transient-Mark Voice-Lock

How can I identify what is doing this?


texts: How to write a helm persistent-action to open a file at a particular line number?

texts:
I have written a helm-extension that at the end shows a list of entries where each entry is like this:

  module_name function_name file-path line-number

I am now writing a persistent-action that will open the the file at a particular line number on each entry.

(defun decode-bt--open-file (line &optional persistent)
    (let ((file (match-string 3 line))
          (line-number (string-to-number (match-string 4 line)))
          (text (match-string 2 line)))
      (find-file (if (file-name-absolute-p file) file (concat dir file)))
      (goto-line (line-number))
      (if persistent (helm-highlight-current-line))))

(defun decode-backtrace-command ()
  (interactive)
  (setq backtrace-alist nil)
  (helm :sources '(some-helm-source)
        :truncate-lines t
        :action (lambda (line) (decode-bt--open-file line))
        :persistent-action (lambda (line) (decode-bt--open-file line t))
        :buffer "*helm backtrace*"))

This fails with the following error, Wrong type argument: stringp, nil

What am I doing wrong?


texts: How to make Emacs align-regexp work with leading spaces

texts:
If I try and use emacs C-u align-regexp on the below with \(\s-*\)| and 1 and 1 and y I get an incorrectly formatted result:

Foobar Foobar foobar| foobar foobar |
         ||

Incorrectly formatted result:

Foobar Foobar foobar                  | foobar foobar |
                                      |               |

Note the large amount of whitespace before the |.

using a non C-u modified align-regexp works as expected.

Can anyone explain what's going on? Can someone also explain the dash in the \(\s-*\) part of the regexp? Thanks in advance.


texts: How to get python-x (eval-in-repl) to work?

texts:
I'm looking to be able to do the same thing as ESS but for python, ie to be able to have two windows side by side one with python shell and the other with text file and send current line or block pressing C-enter or C-p. So I tried to install (python-x) but I don't seem to be able to do that, I tried to install (eval-in-repl) (all this through the MELPA system) but none of it seems to work as when I select python-mode or python-activate nothing happens, and when I open M-x shell then split windows with a python file C-ret isn't binded. Me adding (python-x-setup) in my .spacemacs raise an error at the start.

Any idea how I am supposed to install and setup a package so I can send lines to python shell (or any shell in general) ? I got spacemacs based on emacs 25.1.1

I can run run-python however it opens a shell but how do I get to feed it from a persistent text file ?


texts: Render structural markup and hide comments in org-present-mode?

texts:
I'm giving a presentation with org-present-mode. I'd like to be able to center text and format quotations nicely, as described in the structural markup section of the org-mode docs. I'd also like to be able to make notes to myself in comments that won't display when I give the presentation.

Can I get org-present-mode to do this? I need to be able to execute elisp and open up new buffers within the presentation so exporting to HTML/PDF and viewing it externally isn't an option. If I could export it to a scratch buffer that's still in normal org-mode but with the formatting applied, that would work, but it's not clear to me how to do that.


texts: Magit: amend the last commit with sign off

texts:
What if I forget to sign-off my last commit, how can I fix the last commit within Magit?

I can do that with git command:

$ git commit --signoff --amend

Of cause I can write the sign-off by hand in the rebase reword buffer, but does Magit provide easy way to do?


texts: pdf-view-midnight-minor-mode does not change background color

texts:
The pdf (black text on white background) I'm currently reading in PDFView with pdf-view-midnight-minor-mode enabled only changes the color of the text from black to gray but the background remains the same white (or the difference is so little that I can't notice it).
What can I do fix this?


texts: How do I clean up my local commits and rebase to upstream master in magit?

texts:
I have forked the interleave package.

I made certain commits in my fork but now I want to discard them. I added the remote upstream branch (master branch by the interleave author), fetched it and rebased to upstream/master.

But now the magit status shows the below:

Local:    master ~/.emacs.d/elisp/interleave/
Remote:   master @ origin (http://kaushalmodi@github.com/kaushalmodi/interleave)
Head:     5a9e4ce Refine docs
Tag:      v0.4.0 (8 ahead)

Unpulled commits:
3b836ef Merge branch 'master' of http://github.com/kaushalmodi/interleave
a297270 Merge org sorting fix from upstream
7a855c3 Fix the org-sort-entries issue
57b68fd Merge branch 'master' of http://github.com/kaushalmodi/interleave
39b872a Merge org sorting fix from upstream
88857ea Fix the org-sort-entries issue
9e53d4b Merge org sorting fix from upstream
50939fa Fix the org-sort-entries issue

The above shows my recursive failed attempts to do a clean rebase.

How do I get rid of those Unpulled commits so that the fork master commit hash matches with the original master commit hash?

I have already tried the git reset --hard <upstream master commit hash> method as suggested in this SO thread but that did not help; I simply want to get rid of all the unpulled commits so that I can do c c in magit.


texts: can I have a link to a specific point of an external org file?

texts:
Is it possible to have a link to a specific heading (e.g. identified by a CUSTOM_ID property) of an external org file?
The only relevant example in the external links section of the manual seems to be to an org-file as whole (and not to a heading of it).


texts: Copy and paste between Emacs in an X terminal and other X applications

texts:
I am running Emacs in Gnome-terminal on Ubuntu.

The way I know to copy and paste between emacs and other applications is by Ctrl+C and Ctrl+V, which I think is by the terminal emulator.

A problem with that is it will copy the line continuation symbol \ in Emacs.

How can I do that flawlessly? Can you explain why your way works? Thanks.

Btw, I asked a similar question with output of less, which I heard uses vi. If possible, could you also take a look at it?


texts:
I want to access the first entry of a :LOGBOOK: drawer independently of the visibility of a subtree: folded, partially folded, or unfolded. This function worked on 9.1.9 in the first two cases (folded and partially folded):

(defun my-org-clock-goto-next-clock ()
  (interactive)
  (org-back-to-heading)
  (search-forward "LOGBOOK:")
  (org-cycle 3)
  (forward-line)
  (move-beginning-of-line nil)
  )

I upgraded to Org mode 9.3.3 and (org-cycle 3) no longer unfolds a subtree.  At a top-level heading, I see a message:

Already at the top level of the outline

I read the manual on local and global visibility cycling and could not find how to set a subtree to unfolded.

What is the command to unfold all contents of a subtree regardless of the initial state?


texts: does one has to explicity enable python-mode etc. to work with python files?

texts:
Sometimes I see people talking about enabling python-mode and so on. Is that only necessary for older emacs versions? I thought, the respective mode is enabled automatically when opening a corresponding file...

Please clarify

edit: According to this topic they can work in combination. This leaves me wondering, what the python-mode package additionally brings to the table that is not already provided by the build-in python.el


texts: Unbalanced quotes auto-inserted in AUCTeX mode

texts:
This seems like it should be a very basic question, but I cannot find an answer anywhere.

When writing in AUCTeX mode the auto-inserted paired quotation marks are now unbalanced. That is, when I type the double quote button, I get two backpacks and ONE single quote, rather than two backticks and two single quotes, as expected: ``' instead of the two '' after the backticks. (Sorry that looks odd...I couldn't get two backticks in two places without it converting into a code block).

Note that I do not have this problem in other modes. All other text entry modes have balanced quotes auto-inserted. And the problem under AUCTeX seems limited to quotes (I have not found any braces, parens, brackets or other pairs that are unbalanced).

This has happened in the past month, and I don't recall installing anything new that I thought would conflict. I have been trying to uninstall modes/packages/etc., changing my .emacs file, and other tweaks to fix the problem, or at least figure out where the problem arises. But so far, no luck.

If it helps, here are the list of minor modes running when I am editing a .tex file:

Enabled minor modes: Abbrev Anzu Auto-Composition Auto-Compression
Auto-Encryption Auto-Fill Auto-Insert Centered-Cursor Column-Number
Company Delete-Selection Desktop-Save Diff-Auto-Refine Diff-Hl
Electric-Indent Erc-Autojoin Erc-Button Erc-Fill Erc-Irccontrols
Erc-List Erc-Match Erc-Menu Erc-Move-To-Prompt Erc-Netsplit
Erc-Networks Erc-Noncommands Erc-Pcomplete Erc-Readonly Erc-Ring
Erc-Spelling Erc-Stamp Erc-Track Erc-Truncate File-Name-Shadow Flx-Ido
Flycheck Flyspell Font-Lock Global-Anzu Global-Auto-Revert
Global-Company Global-Diff-Hl Global-Flycheck Global-Font-Lock
Global-Hl-Line Global-Undo-Tree Ido-Ubiquitous Latex-Math Line-Number
Magit-Auto-Revert Menu-Bar Mouse-Wheel Prelude Prelude-Global
Projectile Projectile-Global Recentf Reftex Savehist Shell-Dirtrack
Show-Smartparens Show-Smartparens-Global Size-Indication Smartparens
Sublimity Tex-Pdf Tooltip Transient-Mark Undo-Tree Visual-Line
Volatile-Highlights Which-Function Whitespace Winner

(Geeze, that seems like too many. Maybe a topic for another question.)


texts: Call emacs function from terminal and obtain the same behaviour

texts:
I have this simple function that opens an external shell (st) in the same directory of the current buffer:

(defun external-shell-in-dir ()
  (interactive)
  (start-process "st" nil "st"))

However, if I type in the terminal emacsclient -e "(external-shell-in-dir)" it opens a terminal in my home directory and not in the directory of the current window of emacs.

By the way, I am using spacemacs and I need this for a script to use inside i3wm.


texts: How can I change yank/delete to show relative line numbers during the yank/delete in evil?

texts:
I use evil via spacemacs.  When I use yank, it’s mostly whole line numbers – like y20y. To a lesser extent, this is often true of delete – d10d

Is there anything I can add to my Spacemacs config to toggle on the relative line numbers when I press the first y and to toggle it off if I complete or cancel the yank? And the same for delete? This would make it obvious how many lines I need to yank. It feels like something that should already exist because it is a quite common use case.


texts: org-agenda tags-todo hierarchy weirdness

texts:
There's an interesting question about how to view the hierarchy of TODO keywords in org-agenda which shows two different approaches:

use the "%l" specifier in org-agenda-prefix-format
set org-tags-match-list-sublevels to 'indentation

But I can't seem to get either to work.

Using the first method:

(setq org-agenda-custom-commands
      '(("c" "My TODOs"
         ((tags-todo "mytag"
                     ((org-agenda-prefix-format " %e %l ")
                      (org-tags-match-list-sublevels t)))))))

I get a backtrace:

Debugger entered--Lisp error: (wrong-type-argument buffer-or-string-p 3)
  get-text-property(0 extra-space 3)
  (concat level "" (get-text-property 0 (quote extra-space) level))
  (if (equal level "") "" (concat level "" (get-text-property 0 (quote extra-space) level)))
  (format "%s" (if (equal level "") "" (concat level "" (get-text-property 0 (quote extra-space) level))))
  (format " %s %s %s " (format "%38s" (if (equal breadcrumbs "") "" (concat breadcrumbs "" (get-text-property 0 (quote extra-space) breadcrumbs)))) (format "%6s" (if (equal effort "") "" (concat effort "" (get-text-property 0 (quote extra-space) effort)))) (format "%s" (if (equal level "") "" (concat level "" (get-text-property 0 (quote extra-space) level)))))
  eval((format " %s %s %s " (format "%38s" (if (equal breadcrumbs "") "" (concat breadcrumbs "" (get-text-property 0 (quote extra-space) breadcrumbs)))) (format "%6s" (if (equal effort "") "" (concat effort "" (get-text-property 0 (quote extra-space) effort)))) (format "%s" (if (equal level "") "" (concat level "" (get-text-property 0 (quote extra-space) level))))))

The breadcrumb representation works, but...:

(setq org-agenda-custom-commands
      '(("c" "My TODOs"
         ((tags-todo "mytag"
                     ((org-agenda-prefix-format " %e %b ")
                      (org-tags-match-list-sublevels t)))))))

...my headlines are too long and/or nested to neatly fit on the screen using breadcrumbs.

The second method successfully indents the headlines using dots, but it also obliterates the effort times with spaces:

(setq org-agenda-custom-commands
      '(("c" "My TODOs"
         ((tags-todo "mytag"
                     ((org-agenda-prefix-format " %e ")
                      (org-tags-match-list-sublevels 'indented)))))))

I tried swapping out the effort for breadcrumbs:

(setq org-agenda-custom-commands
      '(("c" "My TODOs"
         ((tags-todo "mytag"
                     ((org-agenda-prefix-format " %b ")
                      (org-tags-match-list-sublevels 'indented)))))))

...and that is not obliterated - it shows the breadcrumbs, then indentation dots, then TODO keyword and headline.

Have I just unluckily run into two different bugs or have I done something stupid? I want mytag TODOs with effort and indentation.

GNU Emacs 24.4.1

org 8.2.10


texts: Org-mode: Using sparse tree to search through timestamps (non-scheduled, non-deadlines)

texts:
I am aware that I able to use sparse tree to search "[b]efore-date" with C-c/b or search "[a]fter-date" with
C-c/a.

However, I recognise that seems to only be with dates that are schedules or deadlines.

Is it possible to use sparse tree or something similar to filter my org-mode bullets by time-stamps? Say in the context of using org-mode to do a logbook/diary of sorts.

Or is the best solution input the time-stamps as schedules?


texts: something changes the default face in my .emacs

texts:
Debian Sid, emacs25, cinnamon 3.2.7

In my ~/.emacs I have

(custom-set-faces
 ;; custom-set-faces was added by Custom.
 ;; If you edit it by hand, you could mess it up, so be careful.
 ;; Your init file should contain only one such instance.
 ;; If there is more than one, they won't work right.
 '(default ((t (:inherit nil [...] :foundry "microsoft" :family "Consolas")))))

When I login in X using, e.g. xfce and start emacs I have that the default face uses Consolas as I want, when I login using cinnamon and start emacs I have that the default face uses LucidaTypewriter (that is a bitmapped font)!

In the second case M-x customize-face RET default RET shows me a customization buffer where the font family is LucidaTypewriter, while in my
~/.emacs I still have a reference to Consolas.

«edit1»
I forgot to mention: if I evaluate the custom-set-faces form, as it is stored
 inside my .emacs, during a Cinnamon session the default face is reversed from LucidaTypewriter to Consolas as expected.

I have no problems on the Emacs side (at least I hope so...), I just want to understand what is happening and, possibly, avoid the small inconvenience of resetting the face to my liking.
«/edit1»

«edit2»
I'm going to address some questions raised in a comment (thank you @jimmij).

Usually I start Emacs from the panel, the command that is used is always (i.e., in Cinnamon and in XFCE)

/usr/bin/emacsclient -c -a ""

but if in a Cinnamon session I start Emacs from the command line I have exactly the same behaviour ("wrong" font).
The ~/.emacs file is correctly evaluated (I see all my customizations) and no error is reported.
The *Messages* buffer

Loading 00debian-vars...done
Loading /etc/emacs/site-start.d/50asymptote.el (source)...done
Loading /etc/emacs/site-start.d/50autoconf.el (source)...done
Loading /etc/emacs/site-start.d/50dictionaries-common.el (source)...
Loading debian-ispell...
Loading /var/cache/dictionaries-common/emacsen-ispell-default.el (source)...done
Loading debian-ispell...done
Loading /var/cache/dictionaries-common/emacsen-ispell-dicts.el (source)...done
Loading /etc/emacs/site-start.d/50dictionaries-common.el (source)...done
Loading /etc/emacs/site-start.d/50slime.el (source)...
Loading /usr/share/emacs/site-lisp/slime/slime-autoloads.el (source)...done
Loading /etc/emacs/site-start.d/50slime.el (source)...done
Loading /etc/emacs/site-start.d/50texlive-lang-english.el (source)...done
For information about GNU Emacs and the GNU system, type C-h C-a.
Mark set

Re X resources database

$ xrdb -q | grep -i emacs | grep -vi xemacs
$

I have no resources concerning Emacs, irrespective of who set them.

«/edit2»

Who's playing behind my back? and how could I  preempt their move?

ps the [...] ellipsis in the code snippet just stays for a long sequence of default values.

---------------------------- UPDATE -----------------------------
ps (writing 24h later) installing the emacs25-lucid package "solved" my problem, in the sense that now a freshly started Emacs uses Consolas — however, this at least leaves open my question "Who's playing behind my back?" with respect to the most common choice of installing the GTK gui version of Emacs.


texts: aspell exited with signal Trace/BPT trap: 5

texts:
I am using GNU Emacs 24.3.1 on Mac Mavericks (Darwin Kernel Version 13.4.0). When I run ispell command I get the error as in the title. I cannot do spell check. Anybody has a hint?

This is the part of my .emacs that regards ispell:

(setq ispell-program-name "/usr/local/bin/aspell")
(setq ispell-program-name "aspell"
      ispell-dictionary "english"
      ispell-dictionary-alist
      (let ((default '("[A-Za-z]" "[^A-Za-z]" "[']" nil
                       ("-B" "-d" "english" "--dict-dir"
                        "/Library/Application Support/cocoAspell/aspell6-en-6.0-0")
                       nil iso-8859-1)))
        `((nil ,@default)
          ("english" ,@default))))


texts:
In ruby-mode, using hs-minor-mode (hideshow) you can hide almost any block of code, but heredocs.

I've tried adding "LONG_HEREDOC" to hs-special-modes-alist, but it didn't worked:

(eval-after-load "hideshow"
  '(add-to-list 'hs-special-modes-alist
                 `(ruby-mode
                   ,(rx (or "def" "class" "module" "{" "[" "do" "<<LONG_HEREDOC")) ; Block start
                   ,(rx (or "}" "]" "end" "LONG_HEREDOC"))                       ; Block end
                   ,(rx (or "#" "=begin"))                        ; Comment start
                   ruby-forward-sexp nil)))

I think it has todo with "ruby-forward-sexp". It doesn't seem to work with heredoc comments.

Does any one knows how to solve this?


texts:
I'm using a fairly frame-oriented workflow (or trying to).  I've run into something strange.  If I write this:

(defun find-file-existing (filename)
    "Edit the existing file FILENAME.
Like \\[find-file], but only allow a file that exists, and do not allow
file names with wildcards."
    (interactive (nbutlast (find-file-read-args "Find existing file: " t)))
    (if (and (not (called-interactively-p 'interactive))
             (not (file-exists-p filename)))
        (error "%s does not exist" filename)
     (find-file-other-frame filename)
     (current-buffer)))

Then commands which use find-file-existing do what I want, including running the command directly from SPC SPC.

If I write this:

(defalias 'find-file 'find-file-other-frame)

Or this:

(defun find-file (filename)
    (interactive (nbutlast (find-file-read-args "Find file: " t)))
    (if (and (not (called-interactively-p 'interactive))
             nil)
        (error "%s does not exist" filename)
     (find-file-other-frame filename)
     (current-buffer)))

Then commands which use find-file (including running it from SPC SPC) do open the file in a new frame, but also change to that buffer in the current frame.

I've been over the code quite a bit and tried a few other variants, but the code paths seem almost the same to me (just changing if there is a file-existing check or not) and it's so strange that one does something different than the other.  Anyone have any ideas how this could be happening?  What should I be looking for?


texts: Efficient way to insert multiple file links (residing in the same directory) into a org file with helm

texts:
Suppose I edit an org-file, say /foo/bar/file.org and I want to insert links to multiple files living in another path, say /another/path/to/files/.
A stupid way to do this would be to call helm-find-files, navigate from /foo/bar/ to /another/path/to/file and insert the link to the first file via C-c @ (and enter the link name/description). Then I repeat the complete procedure for all other files.
Slightly more efficient would it be to use helm-resume with universal argument (e.g. C-u C-c h b) and then resume find files. Then there is no need to navigate from one path to the other each time.
I also tried to mark multiple files (via Alt-SPACE) and then press C-c @, but that doesn't work.
So is there a significantly more efficient way to do the same job?


texts: How to use function update-file-autoloads and and variable generated-autoload-file?

texts:
Let's say I have Emacs Lisp library ~/emacs/my-lib.el with contents:

;;;###autoload
(defun my-func()
  "hello"
  (interactive)
  (message "Hello"))

(provide 'my-lib)

I would now like to produce a file ~/emacs/my-lib-autoload.el with autoload statements for ~/emacs/my-lib.el.
The documentation for update-file-autoloads says ( "C-h f update-file-autoloads" )

  (update-file-autoloads FILE &optional SAVE-AFTER OUTFILE)

  Update the autoloads for FILE. If prefix arg SAVE-AFTER is non-nil,
  save the buffer too.

  If FILE binds generated-autoload-file' as a file-local variable,
  autoloads are written into that file.  Otherwise, the autoloads file
  is determined by OUTFILE.  If called interactively, prompt for
  OUTFILE; if called from Lisp with OUTFILE nil, use the existing value
  ofgenerated-autoload-file'.

So from this information I figured I should be able to supply a non-nil OUTFILE argument. However, trying to run (from scratch buffer) :

(update-file-autoloads "~/emacs/my-lib.el" t "~/emacs/my-lib-autoload.el")

Gives error wrong-type-argument stringp nil

The following two approaches work though:

Setting generated-autoload-file as a global variable, for example adding  (setq generated-autoload-file "~/emacs/my-lib-autoload.el") to my Emacs init file (~/.emacs)
Adding generated-autoload-file as a local file variable at the end of file ~/emacs/my-lib.el

For example:

;; Local Variables:
;; generated-autoload-file: "~/emacs/my-lib-autoload.el"
;; End:

Question:

Why does not

(update-file-autoloads "~/emacs/my-lib.el" t "~/emacs/my-lib-autoload.el")

work when the variable generated-autoload-file is nil?


texts: how do I capture point in arbitrary file as orgmode external file link?

texts: I had this once upon a time but I have misplaced the bit that did it.  In an arbitrary file at point I want to make an external file orgmode link that sticks around long enough to paste elsewhere.  I am sure someone did this before as I used to have it.  But alas, I have misplaced it.


texts: Adding a lambda function as hook in use-package

texts:
I'm trying to adapt this answer to use-package elegantly. It requires that I  hook a lambda function to python-mode. I came up with this solution — which works:

(use-package python
 :hook
  (python-mode . (lambda ()
                   (setq indent-tabs-mode t)
                   (setq tab-width 4)
                   (setq python-indent-offset 4))))

but I find it inelegant, as it requires me to repeat "python-mode" inside the use-package for python (shouldn't that be obvious?). Is there a better way, and if not, why? I'm not sure I understand well the hook process in use-package.


texts:
sort-fields and sort-numeric-fields work great; but the field separator is whitespace. I would like to use a different delimiter (e.g.: [colon-char]).

I want this feature because I find myself resorting the passwd files records by UID via vipw.

I suppose I could start a shell and run something like sort -n -t ':' -k3 /etc/passwd and replace; but that seems clumsy and sort-numeric-fields is tantalizingly close to perfect.


texts: How to have a tag replace its parent in web-mode? (Equivalent to paredit-raise-sexp in paredit)

texts:
I'm having a hard time searching for the answer to this, probably I'm using the wrong terminology. How do I have a child element replace its parent element (the parent element deleted completely and the child element taking the parent's place in the DOM.)

If I have the following code:

This is a paragraph.

And my cursor is at the beginning of the element "child" (or alternatively I have selected the entire element), is there a command that would transform it to the following:

This is a paragraph.

I perform a similar function frequently in paredit using paredit-raise-sexp, but this is my first time working in HTML and I can't find how to do it in web-mode. I feel like it's probably staring me in the face but I'm missing it.


texts: How do I set intero-mode as default for my Haskell buffers instead of haskell-mode?


texts: Receive windows manager notifications of display changes

texts:
Is there a way for emacs to receive display changes notification from the windows manager? I understand this might be an OS dependent question, so I'm particularly interested in the interaction between emacs and Gnome 3 windows manager (on Linux of course).
I'd like emacs to invoke certain functions when such event occurs.


texts:
Hi I would like to use
C-c a m
To create a todo list that is filtered by tags.
If I have a tag like :Makeamilliondollars:
I would like to be able search for it using a wildcard.
Eg I would like to enter
Makea
I tried
Makea*
and this does not work.
Looking at the docs:
11.3.3 Matching tags and properties
https://orgmode.org/manual/Matching-tags-and-properties.html
The only example given for a wildcard search is:

For example, ‘work+{^boss.*}’ matches headlines that contain the tag ‘:work:’ and any tag starting with ‘boss’.

So I am wondering in my case do I need to use
{^Makea.*}
That seems like a lot of extra characters to type in each time I want to do a wildcard search.
Could someone tell me what the minimum additional characters are to do a wildcard search?


texts: How to change color of "font-lock-add-keywords"?

texts:
I found this piece of code to change org-mode list elements from dashes (-) to circles (•):
(font-lock-add-keywords 'org-mode
                          '(("^ *\\([-]\\) "
                             (0 (prog1 () (compose-region (match-beginning 1) (match-end 1) "•"))))))

It works wonderfully, but I cannot figure out how to change the color of the circle to red. I tried reading the documentation of font-lock-add-keywords, but the syntax seems quite cryptic to me. Any help, pointers towards more information, or suggestions on how to achieve what I want would be most welcome.
EDIT:
Based on NickD's comment and on a blog post by Kitchin on colorizing strings, I ended up with the following:
(font-lock-add-keywords
   'org-mode
   '(("^ *\\([-]\\) "
      (0 (prog1 () (compose-region
                    (match-beginning 1)
                    (match-end 1)
                    (propertize "•" 'font-lock-face '(:foreground "red"))))))))

But that doesn't seem to do the trick. I guess the compose-region function must be ignoring any text properties, as inserting the propertized string directly in the buffer does work.
Any help is highly appreciated.


texts: Fontify headline with todo keyword color

texts:
I would like to fontify headlines with the same color/weight as their TODO keywords. So for example, the default is like this:

TODO Headline

And I want it to look like this:

TODO Headline

Any ideas?


texts: Org-Mode LaTeX export with section number, name and page in internal links

texts:
I export my Org-Mode notes with internal links to LaTeX and I want it to look like this ''Section 1.1 [Section name], page 99'' (Like in the Org Manual). I use this construction:

* Chapter 1
** Section 1.1
 :PROPERTIES:
 :CUSTOM_ID: section-1
 :END:
* Chapter 2
** Section 2.1
I want a reference to Section 1.1 from here (See #section-1)

But I only get the number of the section ''1.1'' as a result, not ''Section 1.1 [Section name], page 99''. What options do I need to use?


texts:
The file-writable-p docstring says:

  Return t if file FILENAME can be written or created by you.

In Windows you cannot usually write on files when they are used by a different app. In these instances you get a permission denied error since the process blocks the access.

For example, in most of the viewers, if you open ~/foo.pdf,  you cannot write access to it.
However:

(file-writable-p "~/foo.pdf")

still returns t.  Therefore, with ~/foo.pdf open,

(if (file-writable-p "~/foo.pdf")
    (with-temp-file "~/foo.pdf" (insert "Hello World")))

returns the error: (file-error "Opening output file" "Permission denied" .....
The same happens with:

(if (file-writable-p "~/foo.pdf")
    (delete-file "~/foo.pdf"))

Is this the way file-writable-p is intended to work?
If so, which is the proper path to safely write some output to a file?


texts:
evil-define-key's docs say it "create[s] a STATE binding from KEY to DEF for KEYMAP."

What is a "state"? What is a "state binding"? Emacs doesn't have "states" as far as I know?

My current understanding is that every keypress in Emacs does a lookup in the global key map, which is a literal mapping (like a dictionary in Python, or a "hash" in Ruby) from keys to either functions or another keymap. I know Evil has many different keymaps, one for each state. Isn't an Evil state just a keymap? If so, the description of evil-define-key almost makes sense; it creates a mapping from key to "DEF" in the relevant state keymap, but that only explains 3 out of the 4 parameters, so I must still be missing something. If my train of thought here is correct, then evil-define-key takes 2 keymaps: a state keymap and some other keymap. Why?


texts: Org mode to latex exports themes or templates

texts:
Where can i find some good org to latex export templates, for example, i found some good ones for HTML exports see fniessen excellent work here
is there any similar projects for org-to-latex export?


texts: create new file helm-find-file with ffap

texts:
I have helm-find-files bound to C-x C-f.

When I use it with a filename at point, and the file exists, it uses ffap to offer me that file, which is nice.

But when the file does not exist, it just offers the contents of a directory.

MWE: suppose in a LaTeX buffer I have

\input{/tmp/foo.tex}

with the point on the filename, but the file itself does not exist. How could I make helm-find-files offer creating and opening it as an option?


texts: Ways to render latex-like formula like mathjax in Emacs

texts:
Assume one has a latex-like formula as the following which is usually rendered by mathjax in webpages supporting it (like wordpress):

For all positive integers {n} one has \displaystyle \frac{1}{n+1} \leq \frac{1}{n}

What are different ways to render these formulas like mathjax within Emacs?

To be precise the aim is that mathjax to render in the Emacs buffer (like latex preview via AUCTeX). Other solutions without using mathjax is also welcomed.


texts:
When I hit the wrong key in a folded org-mode buffer and I hit undo, the cursor normally jumps to some folded location and it's pretty hard to understand what is going on.

Expanding the parents of the current location after hitting undo does not seem to expand the right branch (it just positions me somewhere else?).

Would it be possible to make it so that, when undoing, the parts of the tree that are being touched are fully shown?


texts: Emacs org-mode, agenda view, discover overlapping tasks

texts:
If I have following scheduled items in my org file:

** meeting a

   SCHEDULED: <2015-11-12 Thu 21:00-23:00>

** meeting b

   SCHEDULED: <2015-11-12 Thu 22:00-23:00>

which generates following lines in the agenda view:

  annotations:21:00-23:00 Scheduled:  meeting a

  annotations:22:00-23:00 Scheduled:  meeting b

How can highlight overlapping items like these? I thought that v c in the agenda view would show them, but no. The case above is quite obvious, but in the case of a recurring task, it would not be feasible to review all items.


texts:
I see that minor modes defined via define-minor-mode have a variable that has the same name as the function and the following documentation:

  Setting this variable directly does not take effect; either customize
  it (see the info node ‘Easy Customization’) or call the function
  ‘editorconfig-mode’.

However, customizing doesn't seem to work for me.  The value of the variable ends up as nill, “CHANGED outside Customize”, and the minor mode is not enabled unless I additionally add the following to my .emacs:

(editorconfig-mode 1)

In this example I'm using editorconfig-mode, but I have the issue with other modes too.

What am I missing?  Do I need to do something extra or in a different order to get these customized variable to take effect?


texts: Getting the `#+EXPORT_FILE_NAME` value in an org-buffer

texts:
I'm trying to retrieve the value of the #+EXPORT_FILE_NAMEproperty in an org-mode buffer using Emacs Lisp in order to automate some calls of (shell-command "foo %s" export_file_name).

Is there a function that returns this value directly? I guess so, since it is used in all org-mode export backends. But I've just spent a lot of time going through the documentation and I can't find anything satisfactory (or that works properly).


texts: IDO mode: How to go to beginning of line in minibuffer?

texts:
When using IDO mode when I start searching for files it always begins in the working directory of my current file.

Usually I like this, however, if I want to search in a significantly different directory I like to press C-a to go to the beginning of the minibuffer.  However, with IDO that does not work and I stay in my current directory.

Is there a way to change this and go to the beginning?

I suppose I could just type / but...old habits die hard.


texts: Do not autocomplete with company if point is behind a possible completion

texts:
In other words, let point be denoted by ^, if I first type asarray, then move point to the beginning of the word, and type scipy., i.e., end up with scipy.^asarray, don't show possible completions for scipy. (asarray is already a completion). If asarray were incomplete, e.g., asar, then show possible completions for asar. At the moment, it shows all completions as though nothing were after point.

Is there an easy way to handle this?


texts:
The emacs command from emacs23-lucid under wheezy honors the

-iconic -xrm '*iconX: 3350' -xrm '*iconY: 300' -xrm '*bitmapIcon: off'

command-line arguments. But emacs from emacs24-gtk under jessie does not.
(The version from emacs24-gtk under jessie does handle -geometry but handles
it incorrectly, or at least differently than emacs23-lucid under wheezy. It
doesn't handle the -5 in -geometry 80x24-5+200 correctly.)

I don't know if this is a gtk-vs-lucid thing, a 23-vs-24 thing, or a
wheezy-vs-jessie thing.

I use this to create a panel of small Emacs icons with just the hostnames for
all of my machines on my desktop. (I run twm.)

Since the gtk version of Emacs seems to be the future (and some machine that I
use only have the gtk version; I can't change that because I don't maintain
them), I'd like to migrate to the gtk version.

How does one achieve the equivalent of the above command-line arguments with
the gtk version?


texts: How to suppress a minor mode's key binding in only certain major modes?

texts:
Suppose that I use minor mode MIN with a whole bunch of major modes.  In one of those major modes, call it MAJ1, MIN's binding for a specific key K is undesirable; I would therefore like to suppress that definition and get Emacs to fall back to either the major mode's definition, if any, or the default in global-map.  However, I don't want to change how MIN handles that key when it's used with any other major mode, and I want to preserve MIN's other effects in MAJ1.  What's the best way to accomplish that?

The specific combination I'm concerned with is Typo minor mode + Markdown major mode (these are both installed as ELPA packages) and the printable character ` (ASCII backtick), which is syntactically significant in Markdown.  typo-mode defines ` to insert ‘ (left single quote) and then replace that with a backtick if pressed again.  99% of the time when I type ` in a markdown file I want the ASCII backtick, so I want to get rid of the typo-mode binding, but only when the major mode is markdown-mode.

Typo mode is activated from text-mode-hook:

(add-hook 'text-mode-hook
          #'(lambda ()
              (auto-fill-mode 1)
              (typo-mode 1)))

The obvious place to put a markdown-specific override is markdown-mode-hook, so I tried

(add-hook 'markdown-mode-hook
          #'(lambda ()
              (local-set-key (kbd "`") 'self-insert-command)))

but that seems to have no effect at all; I'm guessing that the typo-mode keymap only gets applied after markdown-mode-hook finishes.

Complicating matters, markdown-mode has optional electric behavior for `, so ideally what I would be doing is punching a markdown-specific hole in the typo-mode keymap to allow the markdown-mode-map binding to take effect for this key, but if there's no good way to do that, I could live with a solution that just gets it bound to self-insert-command.


texts: replace-regexp-in-string not replacing the entire match

texts:
So, I have a function that sends a URL to bit.ly for shortening and returns the short URL, and a (replace-regexp-in-string), which is supposed to grab the URL out of a string to passes it to that function.

Funny thing is -- both of these work fine on their own, but when I combine them, I end up with a mess.

(defun crshd/shorten-url (url)
  (let* ((bitly-url (format "https://api-ssl.bit.ly/v3/shorten?access_token=%s&format=%s&longUrl=%s"
                            crshd--bitly-api-key
                            "txt"
                            url))
         (response-buffer (url-retrieve-synchronously bitly-url)))
    (with-current-buffer response-buffer
                (buffer-substring (+ url-http-end-of-headers 1) (- (point-max) 1)))))

(replace-regexp-in-string "http.?://[a-z0-9./?&%#-_=]+"
                          'crshd/shorten-url
                          "replace http://emacs.stackexchange.com in this string"
                          nil nil)

And I end up with "replace http://emachttp://bit.ly/2a1zTGW.stackexchange.com in this string"

At the same time, (crshd/shorten-url "http://emacs.stackexchange.com") returns "http://bit.ly/2a1zTGW", as expected.

(defun crshd/foo-url (url)
  "foo")

(replace-regexp-in-string "http.?://[a-z0-9./?&%#-_=]+"
                          'crshd/foo-url
                          "replace http://emacs.stackexchange.com in this string"
                          nil nil)

Also returns "replace foo in this string".

What am I missing here?


texts: org-mode: how to generate clock report for hours worked each day?

texts:
org-clock-report is awesome; however, it reports time spent on each task. Is there any custom command that you use to generate a clock report showing hours worked, across tasks, for each day?

The trouble I've encountered is that, I file my TODO captures under a file+datetree entry.  For example, one TODO task might be filed on Day -2, but I could be working on it -- i.e., clocking in and out -- on Day -2, -1, and today.  So generating a table naively will just show something like:

#+BEGIN: clocktable :maxlevel 4 :scope file :block thisweek
#+CAPTION: Clock summary at [2017-09-23 Sat 11:48], for week 2017-W38.
| Headline                              | Time      |         |       |       |
|---------------------------------------+-----------+---------+-------+-------|
| *Total time*                          | *1d 0:12* |         |       |       |
|---------------------------------------+-----------+---------+-------+-------|
| 2017                                  | 1d 0:12   |         |       |       |
| \_  2017-09 September                 |           | 1d 0:12 |       |       |
| \_    2017-09-11 Monday               |           |         |  1:23 |       |
| \_      look into AAA BBBB project    |           |         |       |
| \_    2017-09-15 Friday               |           |         |  3:33 |       |
| \_      look into XXX YYYY project    |           |         |       |  3:33 |
#+END:

Note that the second TODO task was filed under 2017-09-15 Friday, which was the date I entered the task.  But really, I might have worked on it on Friday, Saturday, etc.  I just want another command to show how many hours I've worked on each day, generating a report such as the following:

2017-09-11 Monday     xx hours yy mins worked (across all tasks)
...
2017-09-15 Friday     zz hours tt mins worked (across all tasks)

Thanks in advance.


texts: How can I enable git auto-commit on a per-file basis?

texts: Can I perhaps add a hook via local variables in the file header?


texts: (wrong-type-argument stringp nil)-error when starting dired

texts:
Dired used to run fine on my machine (Ubuntu 14.04). But for a while now, i keep running into the error (wrong-type-argument stringp nil). This does not only happen with dired but also with other commands taking an argument (from the minibar).

From searching the web it seems that the error message comes up in situations with some misconfiguration, but I haven't been able to figure it out just yet.

Full error message:

Debugger entered--Lisp error: (wrong-type-argument stringp nil)
call-process(nil nil nil nil "--dired")
dired-insert-directory("/home/hb/test/" "-al" nil nil t)
dired-readin-insert()
dired-readin()
dired-internal-noselect("~/test/" nil)
dired-noselect("/home/hb/test/ nil)
dired("/home/hb/test/")
ido-file-internal(dired dired nil "Dired: " dir)
ido-dired()
call-interactively(ido-dired nil nil)
command-execute(ido-dired)


texts: How to find out which function is bound to C-u C-SPC?

texts:
C-u C-SPC is used to

  Move point to where the mark was, and restore the mark from the ring
  of former marks.

When trying to get the function bound to C-u C-SPC with describe-key it just stops processing the query, with reason, in C-u and returns the universal-argument description.

So the question can also extend to "How do you get the function bound to a keymap starting with C-u where it acts differently from an ordinary argument"?


texts:
This may be a more general programming question that just for Emacs Lisp, but I'm wondering when a function should signal an error vs. return nil.

Raising an error is "failing loudly", which is usually a good thing for debugging, etc. But for a function like file-name-directory, which I often use together with buffer-file-name, it often seems unnecessary that I should need to check that buffer-file-name is non-nil so that file-name-directory does not signal an error. In this case, it should be reasonable that file-name-directory of nil is nil.


texts: Change Background Color of Code Block for org-mode LaTeX export

texts:
I'm inserting code fragments in an org-mode document like this:

#+CAPTION: My Caption
#+NAME: fig:figure_name
#+BEGIN_SRC a_language
My code ...
#+END_SRC

In PDF LaTeX export, the code blocks are not easily distinguished from the main text. Ideally, I would like to have a bounding box and/or a light gray background, similar to how Stack Exchange sets apart snippets of code. I've tried changing the LaTeX background color org-mode option, but it didn't seem to do what I want. Is there any easy way to accomplish this?


texts: How to change Org-mode Babel lisp source code block from SLIME to SLY?

texts:
I found ob-lisp.el use SLIME by default to evaluate lisp code.
I want to use SLY to evaluate lisp code. How to change it?
I found the file ob-lisp.el is short. I tried to change slime to sly. But it is not customizable. I hope to define a defcustom for it. So that user can customize it.
But I don't know how to apply this into code.
For example, I define a custom like this:

(defcustom org-babel-lisp-default-implement "slime")

((defcustom org-babel-lisp-implements
   '("slime" "sly")
   "A list of Lisp implements."
   :group 'org-babel
   :version "24.1"
   ;; FIXME: reference code example.
   :type listp))

Then in file ob-lisp.el. Has some places use slime. I want to make them adapt to upper defcustom value. like concate string from value or something else.

(declare-function slime-eval "ext:slime" (sexp &optional package))

(defun org-babel-execute:lisp (body params)
  "Execute a block of Common Lisp code with Babel."
  (require 'slime)
  (org-babel-reassemble-table
   (let ((result
          (funcall (if (member "output" (cdr (assoc :result-params params)))
                       #'car #'cadr)
                   (with-temp-buffer
                     (insert (org-babel-expand-body:lisp body params))
                     (slime-eval `(swank:eval-and-grab-output
....


texts: How to define abbrev boundaries and where to put them?

texts:
I'm new to Emacs and Common Lisp. I'm wanting to use abbrev-mode to replace standard Common Lisp function names with aliases that I have created. So for example, I would like to replace the following standard functions with my aliases:

equalp
alpha-char-p
char<
char/=

Following the example here, I defined my abbrev table in the global-abbrev-table definition in the abbrev_defs.el file in the folder ~\emacs.d\.

However, I discovered that it does not replace connected multi-words or words that contains non-alphanumeric characters (all except the first in my examples). Reading various answers to questions here like this, things I need to do to fix this are:

Create a regexp that will define abbrev boundaries.
I want the regex to match any sequences of characters except white spaces, parentheses and quotes, so I came up with this regexp \\([^\n\t '()\"]*\\), which I tested  using M-x re-builder inside Emacs.
Modify the syntax table with the new regexp by adding the function abbrev-table-put.
I came up with this: (abbrev-table-put global-abbrev-table :regexp  "\\([^\n\t '()\"]*\\)" )

After adding that sexp at the end of my init file, abbrev-mode is now broken.  It no longer replaces any word, but the default abbrev-mode behavior comes back if I comment out that sexp. Adding the sexp to either file abbrev_defs.el  or the end of file abbrev.el doesn't work.

Question: What's the right fix here? Is my regex wrong? Where should I put that sexp? Any other errors I'm doing?


texts:
I'm developing an app in python which sends commands to a running emacs instance. Currently, I start an emacs server and send the commands through the command line, like this:

subprocess.call(['emacsclient', '-e', '(with-current-buffer ' +
                 '(window-buffer (selected-window)) (save-buffer))'])

Is there another way to control to emacs externally, like an API? Because this solution I came up with doesn't seem very elegant to me.


texts: How to "remove" a remapping so that I can access the underlying (remapped) command?

texts:
I use projectile and helm-projectile. Sometimes I like to use helm-projectile-grep to explore the code dynamically, and sometimes I know what I am looking for and I want the speed, and persistence of projectile-grep.

However, when I map projectile-grep to a key, when I use that key it seems to call helm-projectile-grep. This is my current config:

(use-package projectile
  :ensure t
  :demand t
  :config
  (projectile-mode +1)
  (define-key projectile-mode-map (kbd "s-p") 'projectile-command-map)
  (setq projectile-switch-project-action 'projectile-dired)
  (define-key projectile-command-map (kbd "g") 'projectile-grep))

(use-package helm-projectile
  :ensure t
  :demand t
  :after (projectile)
  :bind ("s-f" . helm-projectile-find-file)
  :config
  (helm-projectile-on))

How can I use separate key bindings for helm-projectile-grep and projectile-grep?


texts:
When doing literate programming, I do web development in a single org file, and do org tangle to generate the relevant html and css files.
This works, for a few hours/days. When the number of files in the org file becomes more than 20 for example, it's a real hassle to isearch/navigate between the #+BEGIN_SRC blocks.

I would very much prefer if I can use something similar to the usual emacs way of switching buffers C-x C-b switch-buffer. So in an possible solution, take this org file for example

#+BEGIN_SRC css :tangle public/styles.css
 some css
#+END_SRC

literate discussion here.

** org subheading
  + list item1
  + list item 2

#+BEGIN_SRC html :tangle public/index.html
<!doctype html>
...
#+END_SRC

When I press C-u C-x C-b, I am presented with these literate-buffer-menu options:

public/index.html
public/styles.css

If would switch/focus to one of these begin_src blocks using similar buffer-menu like flow.

Literate programming has been around for about 20 years, emacs more than double that, so I'm wondering other folks ran in to my issue and overcame it.


texts:
Is there a way to indent cl-flet, cl-labels etc. using the CL style without resorting to (setq lisp-indent-function #'common-lisp-indent-function)?

cl-indent.el claims that:

  common-lisp-indent-function is also a suitable function for indenting Emacs lisp code.

But this is far from true. It misindents the :types of defcustoms, the docstring of define-minor-mode, and more.


texts: What templates are available for generating an elisp library?

texts:
At some point I remember encountering a command that generated a skeleton of a properly formatted emacs-lisp library as below:

;;; library.el --- summary

;; Copyright ...

;; Author:
;; Keywords:

;; License

;;; Commentary:
;;

;;; Code:

(provide 'library)

;;; library.el ends here

After some searching I found checkdoc, which prompts for summary, and commentary and code. Is that the only template generation for a new emacs lisp library builtin to emacs core? Are there any tempo or skeleton based templates for a new emacs lisp library builtin to Emacs core, or somewhere else with yasnippet?


texts: Ubuntu Emacs 26.3 svg image viewing not working

texts:
harold@cayse:~$ emacs --version
GNU Emacs 26.3
Copyright (C) 2019 Free Software Foundation, Inc.
GNU Emacs comes with ABSOLUTELY NO WARRANTY.
You may redistribute copies of GNU Emacs
under the terms of the GNU General Public License.
For more information about these matters, see the file named COPYING.

I am setting up a new machine, and svg image display is not working.

All I can get is this small empty square:

Editing it as text works ctrl-C-C:

As do other image formats:

Errors like this show up in *messages*:

ImageMagick error: unable to open file `/tmp/magick-11959NkcV4z0af4jD': No such file or directory @ error/constitute.c/ReadImage/544

Not sure what to try next, thanks in advance for your time and consideration.


texts: Why does this org session src block not give me the right results?

texts:
I am trying to up my literate coding chops and solving some programming challenges with it.

Here is the full writeup of the exercise I'm playing with

Mostly everything works and I understand everything...except that bit all the way at the bottom.

I have

    #+BEGIN_SRC python :session dp-string-gcd :var examples=dp-gcd-examples :results output :exports both
      def get_string_gcd(shorter, longer):
          if not shorter:
              return None
          if len(shorter) > len(longer):
              return get_string_gcd(longer, shorter)
          current_cycle = []
          for ((s, current_cycle), l) in zip(tracked_cycle(shorter), longer):
              if s != l:
                  return None
          return ''.join(current_cycle)

      for (longer, shorter, desired) in examples:
          desired = desired or None
          gcd = get_string_gcd(shorter, longer)
          print(f'gcd({shorter}, {longer}) = {gcd}')
          if gcd != desired:
              print(f'FAILBOY! it should be {desired}\n')
    #+END_SRC

    #+RESULTS:
    : gcd(ABC, ABCABC) = ABC
    : gcd(ABAB, ABABAB) = AB
    : gcd(ABAB, ABABABB) = None
    : gcd(CODE, LEET) = None

but that's not really what I want - I would like the function definition to be in a separate src block

The issue is when I do this

    #+BEGIN_SRC python :session dp-string-gcd :results none
      def get_string_gcd(shorter, longer):
          if not shorter:
              return None
          if len(shorter) > len(longer):
              return get_string_gcd(longer, shorter)
          current_cycle = []
          for ((s, current_cycle), l) in zip(tracked_cycle(shorter), longer):
              if s != l:
                  return None
          return ''.join(current_cycle)
    #+END_SRC

    #+BEGIN_SRC python :session dp-string-gcd :var examples=dp-gcd-examples :results output :exports both
      for (longer, shorter, desired) in examples:
          desired = desired or None
          gcd = get_string_gcd(shorter, longer)
          print(f'gcd({shorter}, {longer}) = {gcd}')
          if gcd != desired:
              print(f'FAILBOY! it should be {desired}\n')
    #+END_SRC

    #+RESULTS:
    : gcd(ABC, ABCABC) = None
    : FAILBOY! it should be ABC
    :
    : gcd(ABAB, ABABAB) = None
    : FAILBOY! it should be AB
    :
    : gcd(ABAB, ABABABB) = None
    : gcd(CODE, LEET) = None

I for some reason start getting the function returning None! in fact it seems like that happens any time that the first block doesn't have :results output. I'm not outputting anything there, I just want the stuff to run in the session.

What is going on that simply changing the results type on the src block can make a python function return something different?


texts: Portable Emacs: Remapping user-emacs-directory

texts:
The Problem

I want to install Emacs on a USB Flash Drive in a portable fashion, that is, Emacs should be able to be run from the UFD, once plugged on a device, without predefined paths to its binaries and save all its persistent data on the UFD.
To obtain this, the Emacs startup script (possibly in the form of an icon for the user to click on) should be able to find the relevant binaries and set the needed directory paths.

Hereafter I take Windows as an example, but my concepts are not platform-specific.

In Windows 90% of the work for a portable Emacs is already done by GNU Emacs, because Emacs for Windows comes as a zipped package, without an installer. According to the docs you have to:

  Unzip the zip file preserving the directory structure, and run bin\runemacs.exe. Alternatively, create a desktop shortcut to bin\runemacs.exe, and start Emacs by double-clicking on that shortcut's icon.

Anyway, when extracting on a UFD, persistent data will not be stored on the UFD, but on the home directory of the host system.

This is what I tried

Let us assume that Emacs has been extracted as emacs on the root of the UFD,  where  there is also a docs folder. In the root I therefore create the following batch script to bootstrap Emacs:

Emacs.cmd
---------
set "HOME=%~dp0docs"
emacs\bin\runemacs.exe   -q   --load emacs\init.el %*

Script Explanation
-q solves side effects due to unwanted  reading/writing of init files on the host system.
At the same time, this requires that some init file equivalent is manually loaded with the --load part. An alternative would be using site-start.el, not bypassed by -q.
Note that paths are relative to the position of the script so there is no need to guess the UFD drive letter.
The same is not true for the home dir. In this case I use the %~dp0 trick, which is converted by the shell to the script parent dir (somewhat like $(dirname "$0") in Bash).
%* lets add add extra arguments to runemacs, when running Emacs.cmd from the console.
Given -q is intended to make a slimmer Emacs, some default settings might be missing and if you need them you have to manually set them in emacs\init.el. By reading superficially Emacs startup.el code, one such missing item is:

(package-initialize)

which should be added to emacs\init.el or alternatively to site-start.el

This setup works pretty well. So now I come to the actual

Question

In the setup above, where the HOME dir is used to store documents,  therefore it would be nice and make sense to have the Emacs settings directory, .emacs.d, outside the document folder.

According to the documentation it should be possible to obtain this result by properly setting the variable user-emacs-directory. Therefore, the following lines should be added to the head of the init file called by the bootstrap script:

init.el
-------
(setq user-emacs-directory
      (expand-file-name (concat invocation-directory "../.emacs.d")))
(setq abbrev-file-name
      (locate-user-emacs-file "abbrev_defs"))
(setq auto-save-list-file-prefix
      (locate-user-emacs-file "auto-save-list/.saves-"))
(cd "~"))

Despite the -q switch, before running init.el other code is run  (this is why the abbreviations and the auto-save directory require a separate setup).

These settings work only partially. In fact, an empty ~/.emacs.d keeps appearing in the home dir.
What library creates the folder?
Is it possible to avoid to make the HOME folder dirty?

Debugging startup.el would help, but it is not possible, as  it is a fake file. Its actual content is dumped into the Emacs binary.


texts: org-agenda-files is a dir, but can't cycle

texts:
I want to cycle through the org-agenda-files who's value is:

org-agenda-files is a variable defined in ‘org.el’.
Its value is ("/home/jenia/Documents/org/")
Original value was nil

But when I press C-' I'm only taken to the very first (alphabetically) file in that dir.

How do I cycle through all the files in the dir?

Here is the dir contents:

  -rw-r--r--  1 jenia jenia    965 10-02 20:03 arch.org
  -rw-r--r--  1 jenia jenia   2000 10-15 18:00 bash.org
  -rw-r--r--  1 jenia jenia    412 2016-04-03  calc.org
   ....

Thanks


texts: How to restore windows registers from saved desktop

texts:
I save a few different windows registers using M-x r w and then save the entire desktop with M-x desktop-save.

I then restart Emacs and load the desktop using M-x desktop-read. If I do M-x r j do jump to one of the previously saved windows registers in the saved desktop I get an error message saying Register doesn't contain a buffer position or configuration.

If I do M-x list-registers every registry is described as Register X contains a rectangle starting with an Unprintable entity.

I do not run Emacs in a terminal, it's a full GUI Emacs and desktop-restore-frames is set to 't'. How should I do to save frame configurations between desktop sessions?


texts:
I am using Flycheck for my syntax highlighting which have been working out great when working with all header and source files in one directory.

I recently decided to add some unit tests to test my code which I added another directory for. The projects compiles and runs without problems. My problem is that in the test/Formula-test.cpp file when i #include "Formula.h" a header from the src/Formula.h folder flycheck can't seem to find it. I get the "error" 'Formula.h' file not found (c/c++-clang).

My project structure looks like this:

.
├── build
│   └── compile_commands.json
├── CMakeLists.txt
├── lib
│   └── googletest
├── src
│   ├── CMakeLists.txt
│   ├── Formula.cpp
│   ├── Formula.h
│   ├── main.cpp
└── test
    ├── CMakeLists.txt
    ├── Formula-test.cpp
    └── main.cpp

Is there any configuration or package that can fix this?

Here is my full config file: https://github.com/Zeppan/configs/blob/master/.emacs


texts: Load a file into a buffer without changing the display

texts:
I have a use-package idle hook that loads my org files into buffers for future use. I want this to be unobtrusive. However, I cannot find any find-file function which loads a file without changing the display.
There are a number of find-file functions in the Emacs manual, but none of these do what I want.

find-file Visit a file.
find-file-read-only Visit a file for viewing, without allowing changes to it.
find-alternate-file Visit a different file instead of the one visited last.
find-file-other-window Visit a file, in another window.
find-file-other-frame Visit a file, in a new frame.
find-file-literally Visit a file with no conversion of the contents.

I thought find-file-literally might be a winner, but it does in fact load the file into the current window.
Is there a function I can use to load files into buffers without any display changes?


texts:
After far too many years of counting the number of characters in the region by doing M-: (- (point) (mark)), I just discovered M-= (count-words-region).  Much better!  But now I'm looking for a way to obtain the number of bytes that the characters in the region occupy in the buffer's coding system--typically, or always really, UTF-8.  Is there an easy way to do this?

For context, I've been doing some code golfing on codegolf.stackexchange.com in a language that supports various Unicode operators, and I need to know how many bytes my submission occupies.  So far I've been saving the region to a file, doing ls -l on it, then deleting it.  I could easily whip up a function to do this automatically, but it seems rather inelegant.


texts: How can I test and use a Perl regular expression interactively?

texts:
Say I have a buffer with text. I would like to test a regular expression (ideally Perl type) against my buffer and have Emacs highlight the matches on it.

For example, the following regexp (taken from Wikipedia):

(?<=\.) {2,}(?=[A-Z])

would match as follows on the following text:

This regular expression in particular matches at least two spaces occurring after period (.) and before an upper case letter.

Does Emacs provide an interactive regular expression matcher for Perl regular expressions?

If the answer to the latter is no:

Is there a reason why native support of Perl regular expressions wasn't (ever) considered in Emacs? (considering that it is a well known standard in Unix/Linux)
How could one proceed about building one such Perl regexp matcher? (perhaps calling Perl under the hood, or pre-converting the Perl regexp to a supported variant?)


texts: How to tell if a emacs library is loaded?

texts:
Is there a function that will tell me for a given library foo if

(require 'foo)

has previously happened?


texts: All the IMAP folders of multiple accounts in wanderlust

texts:
I have two IMAP accounts, I'd like to see all my IMAP folders for both.

With only one account I use "%/" in my .folders file and it works well (but I have the (setq elmo-imap4-default-server ... & co. in my .emacs).

With two accounts I cannot make it work.
I think the problem is that I'm not able to specify credentials for the two "%/".
Is there a solution?

Example ~/.folders:

AccountA {
    %INBOX:username/clear@imap.serverA.com:993!        "Inbox"
    %/
}
AccountB {
    %INBOX:username/clear@imap.serverB.com:993!        "Inbox"
    %/
}


texts: I've set fill-column value to be 80. But, especially for org-mode I want a bit higher fill-column value. Is it possible for org-mode to have a separate fill-column value of say 100?


texts: How to remove fringe when copying from emacs?

texts:
When copying from emacs buffers in a terminal to other application,
I grab the region and copy them and paste it onto another application.
The copied text has a leading whitespace in each line although emacs has no whitespace when editing.
I think the space is due to fringe.
I don't want to turn off fringe, I just want to ignore the fringe when copying, is it possible?


texts: Org-mode -- sub-TOCs for individual sections?

texts:
Inside my org-mode documents, I'd like to do sub-TOCs for individual
sections and subsections.

For example:

#+TOC: headlines 1         # This is the "main" table of contents,
                           # showing just the level-1 headings

* Business operations      # This is a level-1 heading

{{{SUBTOC}}}               # Inserts just the *level-2* headings for this *level-1* section

** Services                # This is a level-2 heading

{{{SUBTOC}}}               # Shows just the *level-3* headings for this *level-2* section

*** Statements of work
*** Changes to statements of work
*** No obligation to agree to statement of work

** Sales of goods          # The next level-2 heading

{{{SUBTOC}}}

etc.

Any suggestions?


texts: Can't switch input sources in the minibuffer during Isearch

texts:
Incremental search doesn't allow me to switch between different input sources, e.g. US English to French, when I'm typing my search string into the minibuffer. Is there a way to fix this?

It happens only when I try to switch input sources with keyboard shortcuts. It doesn't happen with switching by clicking the input source icon in the menu bar.

24.5 OSX desktop version


texts:
What I would like to achieve is a deeper indentation of lines in items in Auctex.

\begin{itemize}
  \item This is what I would like to achieve. The beginning of the
        second line aligns with the beginning of the item content
\end{itemize}

This is the standard behaviour

\begin{itemize}
\item This is what I current get. The beginning of the
  second line aligns with \item instead
\end{itemize}

There is a solution posted here but it unfortunately breaks LaTeX-fill-paragraph (M-q) which is not acceptable to me.


texts:
Q: How does one pronounce magit?

It occurred to me today that I've never said "magit" out loud, and I'd prefer not to make a fool of myself if I ever have to do so.

So: is the g in magit pronounced as:

a j, as in magic, or
a hard g, as in git?

I suppose I've always said it as j in my head, but I could see the other way as well (aside from the unfortunate similarity to "maggot").


texts: Windows eshell alias command line arguments.. how?

texts:
I have alias msexcel (w32-browser "C:/program files/microsoft office/office12/excel.exe") and this means I can do msexcel from eshell and an asynchronous MS Excel will begin to run.

I am looking for ways to do msexcel "C:\\documents\ and\ settings\\me\my\ documents\\book.xlsx".

alias msexcel (w32-browser (format "C:/program files/microsoft office/office12/excel.exe /r %s" $1)) returns the error message (void-variable $1).

How do I send Excel a file name through this eshell alias?


texts: How to Redefine Meta Key to Use Esc Key Only and Allow Using Alt Key for Another Purpose

texts: I am using ubuntu 18.04. The Esc-v scrolls up by a page as expected (classical Emacs command with Esc being the meta key). But I want to use Alt-v as a "paste command". In other words: can I decouple the Alt key from Esc key so that Esc remains as the meta key but the Alt key is used for other stuff?


texts: Yanking into a regexp isearch escapes the metacharacters

texts:
I noticed today that when I yank a string containing regexp metacharacters into an active regexp isearch, the metacharacters all get escaped.  For example, if I've killed the text foo* and yank that string into a search, it becomes foo\*.
My actual use case involved me generating a list of alternatives I wanted to search for in a temporary buffer, and then joining them together with \|.  Something like foo\|bar\|...\|baz.  In the buffer I wanted to search, I started a regexp search and pasted in that string, but it became foo\\|bar\\|...\\|baz.
I haven't been able to find this behavior described in the docs.  I got around it by calling eval-expression and providing my string to search-forward-regexp, but that's obviously kind of a hassle, and moreover doesn't let me repeat the search with a simple C-s.
The behavior I described doesn't seem correct to me, or at least not intuitive, but is it documented somewhere?  If it is correct, are there any other reasonable workarounds?


texts:
When I run a process in the Mac Terminal, it gives me an indication of its progress. Here we see that I am 31% complete on downloading the latest org-mode:

How can I get this same sort of progress indicator, when running a process from within a code block in org-mode?